1.0.6 • Published 6 years ago
sw-webpack-plugin v1.0.6
sw-webpack-plugin
ServiceWorker webpack plugin
Use
install by:
npm i -D sw-webpack-plugin
import in webpack.config.js
:
const SwWebpackPlugin = require('sw-webpack-plugin');
module.exports = {
plugins:[
new SwWebpackPlugin({
// sw.js template file path
sw: '/path/to/sw.js',
// reg to include file to be cache
include: /\.(js|css|html|png|jpe?g)$/,
// reg to exclude file to be cache
exclude: undefined,
// function to modify injectData data before inject _sw into sw.js
reduce: function(injectData) {
injectData = {
assets: shouldCacheFileUrlList,
hash: compilation.hash,
}
},
}),
]
}