1.0.8 • Published 5 years ago

eleventy-plugin-pwa v1.0.8

Weekly downloads
550
License
MIT
Repository
github
Last release
5 years ago

eleventy-plugin-pwa

travis license: MIT eleventy code style: prettier codecov

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

Note

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

Installation

npm i eleventy-plugin-pwa

Add to eleventy config file

const pluginPWA = require("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

License

This code is available under the MIT license.

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago