Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automantically extract vendor chunk #112

Merged
merged 2 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions template/build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ module.exports = {
// when you use electron please set to relative path like ./
// otherwise only set to absolute path when you're using history mode
publicPath: '{{#if electron}}.{{/if}}/',
// add these dependencies to a standalone vendor bundle
vendor: [
'vue',
'vuex',
'vue-router',
'vuex-router-sync',
'promise-polyfill'
],
// disable babelrc by default
babel: {
babelrc: false,
Expand Down
9 changes: 6 additions & 3 deletions template/build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ if (config.electron) {
base.devtool = 'source-map'
}

// a white list to add dependencies to vendor chunk
base.entry.vendor = config.vendor
// use hash filename to support long-term caching
base.output.filename = '[name].[chunkhash:8].js'
// add webpack plugins
Expand All @@ -44,7 +42,12 @@ base.plugins.push(
// extract vendor chunks
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.[chunkhash:8].js'
minChunks: module => {
return module.resource && /\.(js|css|es6)$/.test(module.resource) && module.resource.indexOf('node_modules') !== -1
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),
// progressive web app
// it uses the publicPath in webpack config
Expand Down