diff --git a/examples/vue-chartjs/nuxt.config.js b/examples/vue-chartjs/nuxt.config.js index e6b67f1882..943b5aebf7 100644 --- a/examples/vue-chartjs/nuxt.config.js +++ b/examples/vue-chartjs/nuxt.config.js @@ -7,7 +7,8 @@ module.exports = { ] }, build: { - vendor: ['axios', 'moment', 'chart.js', 'vue-chartjs'] + vendor: ['axios', 'moment', 'chart.js', 'vue-chartjs'], + maxChunkSize: 300000 }, env: { githubToken: '42cdf9fd55abf41d24f34c0f8a4d9ada5f9e9b93' diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 6bb31233c0..d045553741 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -166,6 +166,17 @@ module.exports = function webpackClientConfig() { config.plugins.push(new webpack.optimize.ModuleConcatenationPlugin()) } + // Chunks size limit + // https://webpack.js.org/plugins/aggressive-splitting-plugin/ + if (this.options.build.maxChunkSize) { + config.plugins.push( + new webpack.optimize.AggressiveSplittingPlugin({ + minSize: this.options.build.maxChunkSize, + maxSize: this.options.build.maxChunkSize + }) + ) + } + // https://webpack.js.org/plugins/hashed-module-ids-plugin config.plugins.push(new webpack.HashedModuleIdsPlugin()) diff --git a/lib/common/options.js b/lib/common/options.js index e2d06d56cf..32e84423bd 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -184,6 +184,7 @@ Options.defaults = { profile: process.argv.includes('--profile'), dll: false, scopeHoisting: false, + maxChunkSize: false, extractCSS: false, cssSourceMap: undefined, ssr: undefined,