how to make serwice-worker use of vendor bundle
mayacode opened this issue · 0 comments
mayacode commented
- I'm submitting a support request
webpack version:
2.6.1
sw-precache-webpack-plugin version:
0.11.4
Please tell us about your environment:
OSX 10.12.6
Browser:
Chrome 66.0.3359.139
Current behavior:
When I build service-workers the whole used libraries like moment.js, are added to the build.
Expected/desired behavior:
I would like to make my service worker use the libraries from vendor bundle.
- Webpack configuration:
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
// --
new SWPrecacheWebpackPlugin({
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
return;
}
if (message.indexOf('Skipping static resource') === 0) {
return;
}
console.log(message);
},
minify: true,
navigateFallback: publicUrl + '/index.html',
navigateFallbackWhitelist: [/^(?!\/__).*/],
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/]
}),
// --
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: module => /node_modules/.test(module.resource)
})