1.0.2 • Published 6 years ago

html-webpack-sw-register-plugin v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Install

$ npm install html-webpack-sw-register-plugin

Usage

plugins: [
    new HtmlWebpackPlugin({
        swConfig: {
            swPath: 'sw.js' // the static path of your service worker
        }
    }),
    new SWRegisterPlugin()
]

Take notic of: The static path of service worker is necessary. If you use the relative path that may cause the service worker not be found during the registering.

The recommend ways:

entry: {
    index: './app.js',
    sw: './src/somePaht/sw.js' // this will be build as dist/sw.js, and use 'sw.js' could be registered easily
},
output: {
    path: path.join(__dirname, './dist'),
    filename: '[name].js'
},
plugins: [
    new HtmlWebpackPlugin({
        swConfig: {
            swPath: 'sw.js' // the static path of your service worker
        }
    }),
    new SWRegisterPlugin()
]