serviceworker-webpack-plugins
Simplifies creation of serviceworker files to serve your PWA.
Usage
- install
$ npm i serviceworker-webpack-plugins --save-dev
- setup
webpack.config.js
const ServiceworkerPlugins = moduleexports = // ... plugins: entry: sw: filename: 'sw.js' path: '' register: filename: 'sw-register.js' path: '' include: // [PATH] exclude cacheFiles path
Note
Please pay attention before use:
Insert the following script tag below your body node
Local debugging
- Chrome whiteList Setting:chrome://flags/#unsafely-treat-insecure-origin-as-secure
- Reason: https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features
Key Points
createChildCompiler
/** * @params compilerName * @params outputOptions**/const childCompiler = compilation