mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +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',
|
||||||
'vue-router',
|
'vue-router',
|
||||||
'vue-meta',
|
'vue-meta',
|
||||||
'core-js',
|
this.options.store && 'vuex'
|
||||||
'regenerator-runtime',
|
|
||||||
'es6-promise',
|
|
||||||
'babel-runtime',
|
|
||||||
'vuex'
|
|
||||||
].concat(this.options.build.vendor).filter(v => v)
|
].concat(this.options.build.vendor).filter(v => v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,20 @@ export default function webpackClientConfig () {
|
|||||||
|
|
||||||
// App entry
|
// App entry
|
||||||
config.entry.app = resolve(this.options.buildDir, 'client.js')
|
config.entry.app = resolve(this.options.buildDir, 'client.js')
|
||||||
|
config.entry.common = this.vendor()
|
||||||
|
|
||||||
// Extract vendor chunks for better caching
|
// Extract vendor chunks for better caching
|
||||||
const _this = this
|
const _this = this
|
||||||
const totalPages = _this.routes ? _this.routes.length : 0
|
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(
|
config.plugins.push(
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
@ -47,9 +56,8 @@ export default function webpackClientConfig () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract all explicit vendor modules
|
// Detect and externalize well-known vendor if detected
|
||||||
// Vendor should explicitly extracted even if not used in 50% of the chunks!
|
if (module.context && maybeVendor.some(v => module.context.includes(v))) {
|
||||||
if (module.context && vendor.some(v => module.context.includes(v))) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user