Skip to content

Commit 11c27e4

Browse files
authored
automantically extract vendor chunk (egoist#112)
* automantically extract vendor chunk * no need to use `vendor` option
1 parent 1171d50 commit 11c27e4

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

template/build/config.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ module.exports = {
77
// when you use electron please set to relative path like ./
88
// otherwise only set to absolute path when you're using history mode
99
publicPath: '{{#if electron}}.{{/if}}/',
10-
// add these dependencies to a standalone vendor bundle
11-
vendor: [
12-
'vue',
13-
'vuex',
14-
'vue-router',
15-
'vuex-router-sync',
16-
'promise-polyfill'
17-
],
1810
// disable babelrc by default
1911
babel: {
2012
babelrc: false,

template/build/webpack.prod.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ if (config.electron) {
2121
base.devtool = 'source-map'
2222
}
2323

24-
// a white list to add dependencies to vendor chunk
25-
base.entry.vendor = config.vendor
2624
// use hash filename to support long-term caching
2725
base.output.filename = '[name].[chunkhash:8].js'
2826
// add webpack plugins
@@ -44,7 +42,12 @@ base.plugins.push(
4442
// extract vendor chunks
4543
new webpack.optimize.CommonsChunkPlugin({
4644
name: 'vendor',
47-
filename: 'vendor.[chunkhash:8].js'
45+
minChunks: module => {
46+
return module.resource && /\.(js|css|es6)$/.test(module.resource) && module.resource.indexOf('node_modules') !== -1
47+
}
48+
}),
49+
new webpack.optimize.CommonsChunkPlugin({
50+
name: 'manifest'
4851
}),
4952
// progressive web app
5053
// it uses the publicPath in webpack config

0 commit comments

Comments
 (0)