diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index cfb44d1184..6bbb62c70c 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -18,7 +18,7 @@ export default function webpackBaseConfig ({ isClient, isServer }) { const config = { devtool: this.options.dev ? 'cheap-module-source-map' : 'nosources-source-map', entry: { - vendor: ['vue', 'vue-router', 'vue-meta'] + app: null }, output: { path: resolve(this.options.buildDir, 'dist'), diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 1136db3513..9596497576 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -24,20 +24,28 @@ export default function webpackClientConfig () { config.name = 'client' - // Entry + // App entry config.entry.app = resolve(this.options.buildDir, 'client.js') // Add vendors - if (this.options.store) { - config.entry.vendor.push('vuex') - } - config.entry.vendor = config.entry.vendor.concat(this.options.build.vendor) + // This vendors should explicitly extracted + // Even if not used in 50% of the chunks! + const vendor = [ + 'vue', + 'vue-router', + 'vue-meta', + 'core-js', + 'regenerator-runtime', + 'es6-promise', + 'babel-runtime', + this.options.store && 'vuex' + ].concat(this.options.build.vendor).filter(v => v) // Extract vendor chunks for better caching const _this = this config.plugins.push( new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', + name: 'common', filename: this.options.build.filenames.vendor, minChunks (module, count) { // In the dev we use on-demand-entries. @@ -47,6 +55,11 @@ export default function webpackClientConfig () { return false } + // Extract all explicit vendor modules + if (module.context && vendor.some(v => module.context.includes(v))) { + return true + } + // Total pages const totalPages = _this.routes ? _this.routes.length : 0