@poi/plugin-sw-precache
Integrated [sw-precache-webpack-plugin](https://github.com/goldhand/sw-precache-webpack-plugin) into production configuration to add Progressive Web App support.
Last updated 2 years ago by egoist .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @poi/plugin-sw-precache 
SYNC missed versions from official npm registry.

plugin-sw-precache

Integrated sw-precache-webpack-plugin into production configuration to add Progressive Web App support.

This is basically extracted from create-react-app but as a Poi plugin.

A live example can be found at: https://poi-sw-precache.surge.sh, you can enable offline mode in chrome devtools to check if it works for you.

Install

yarn add @poi/plugin-sw-precache

Usage

Add the plugin to your config file:

module.exports = {
  plugins: [
    require('@poi/plugin-sw-precache')()
  ]
}

Then register service worker in your entry file:

import register from '@poi/plugin-sw-precache/register-service-worker'

register()

To have a full progressive web app support, you need to put your PWA metadata file at ./static/manifest.json, here's an example:


{
  "short_name": "Poi App",
  "name": "My Sample App",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

And of course favicon.ico is also required in this example.

Service worker events

You can use your own version of ./register-service-worker.js to handle service worker events, like what to perform when new updates of your app are available, by default it simply logs a message and users to to refresh browser to see updated version.

License

MIT © EGOIST

Current Tags

  • 10.0.1                                ...           latest (2 years ago)
  • 10.0.0-beta.10                                ...           next (2 years ago)

10 Versions

  • 10.0.1                                ...           2 years ago
  • 10.0.0                                ...           2 years ago
  • 10.0.0-rc.1                                ...           2 years ago
  • 10.0.0-rc.0                                ...           2 years ago
  • 10.0.0-beta.10                                ...           2 years ago
  • 10.0.0-beta.9                                ...           3 years ago
  • 10.0.0-beta.8                                ...           3 years ago
  • 10.0.0-beta.7                                ...           3 years ago
  • 10.0.0-beta.2                                ...           3 years ago
  • 10.0.0-beta.1.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 7
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |