@pkvach/eleventy-plugin-pwa

    1.4.0 • Public • Published

    @pkvach/eleventy-plugin-pwa

    NPM version Maintenance Release Status Issues open Code coverage Quality Gate Status

    An Eleventy plugin to generate service worker. Using Google Workbox to generate service-worker.js based on your dir.output.

    Since (at this moment) eleventy doesn't have any API to do things after build process, this plugin is using monkey patch method to wrap into the finish function in order to run workbox properly.

    Summary

    Getting started

    Installation

    yarn add @pkvach/eleventy-plugin-pwa

    Usage

    Add to eleventy config file

    const pluginPWA = require('@pkvach/eleventy-plugin-pwa');
    module.exports = function (eleventyConfig) {
      eleventyConfig.addPlugin(pluginPWA);
    };

    Read more about Eleventy plugins

    Registering Service Worker

    // in your header templates
    <script>
      if ('serviceWorker' in navigator) navigator.serviceWorker.register('/service-worker.js');
    </script>

    Adding Web App Manifest

    Read The Web App Manifest Guide

    Options

    You can also pass workbox generateSW options directly into the plugin. For example :

    // overwriting destination file and more
    const pluginPWA = require('eleventy-plugin-pwa');
    module.exports = function (eleventyConfig) {
      eleventyConfig.addPlugin(pluginPWA, {
        swDest: './build/sw.js',
        globDirectory: './build',
      });
    };

    Read more about it on workbox generateSW module page

    Built With

    Contributing

    Please read CONTRIBUTING.md for details on our the process for submitting issues and pull requests to us. This repository has a code of conduct, we will remove things that do not respect it.

    Versioning

    We use SemVer for versioning. For the available versions, see the tags on this repository.

    Authors

    See the list of contributors who participated in this project.

    License

    This code is available under the MIT license.

    Acknowledgements

    Install

    npm i @pkvach/eleventy-plugin-pwa

    DownloadsWeekly Downloads

    13

    Version

    1.4.0

    License

    MIT

    Unpacked Size

    27.6 kB

    Total Files

    29

    Last publish

    Collaborators

    • pkvach