goldhand / goldhand/sw-precache-webpack-plugin

how to make serwice-worker use of vendor bundle

Open
#153 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.4k
Forks
101
PR merge metrics
No merged PRs in 30d

Description

* [x] **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)
})
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.