mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix problems with common chunk
This commit is contained in:
parent
e19939c10a
commit
7973d67f5b
@ -72,11 +72,7 @@ export default class Builder extends Tapable {
|
||||
'vue',
|
||||
'vue-router',
|
||||
'vue-meta',
|
||||
'core-js',
|
||||
'regenerator-runtime',
|
||||
'es6-promise',
|
||||
'babel-runtime',
|
||||
'vuex'
|
||||
this.options.store && 'vuex'
|
||||
].concat(this.options.build.vendor).filter(v => v)
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,20 @@ export default function webpackClientConfig () {
|
||||
|
||||
// App entry
|
||||
config.entry.app = resolve(this.options.buildDir, 'client.js')
|
||||
config.entry.common = this.vendor()
|
||||
|
||||
// Extract vendor chunks for better caching
|
||||
const _this = this
|
||||
const totalPages = _this.routes ? _this.routes.length : 0
|
||||
const vendor = this.vendor()
|
||||
|
||||
// This well-known vendor may exist as a dependency of other requests.
|
||||
const maybeVendor = [
|
||||
'/core-js/',
|
||||
'/regenerator-runtime/',
|
||||
'/es6-promise/',
|
||||
'/babel-runtime/',
|
||||
'/lodash/'
|
||||
]
|
||||
|
||||
config.plugins.push(
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
@ -47,9 +56,8 @@ export default function webpackClientConfig () {
|
||||
return false
|
||||
}
|
||||
|
||||
// Extract all explicit vendor modules
|
||||
// Vendor should explicitly extracted even if not used in 50% of the chunks!
|
||||
if (module.context && vendor.some(v => module.context.includes(v))) {
|
||||
// Detect and externalize well-known vendor if detected
|
||||
if (module.context && maybeVendor.some(v => module.context.includes(v))) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user