Coder Social home page Coder Social logo

pkvach / eleventy-plugin-pwa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pvds/eleventy-plugin-pwa

1.0 0.0 0.0 761 KB

An eleventy plugin to generate service-worker for PWA. Powered by Google Workbox

Home Page: https://www.npmjs.com/package/@pkvach/eleventy-plugin-pwa

License: MIT License

JavaScript 99.17% HTML 0.83%

eleventy-plugin-pwa's Introduction

@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

eleventy-plugin-pwa's People

Contributors

dependabot[bot] avatar okitavera avatar pkvach avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.