理想情况下,供应商块散列不应该更改,但是当应用程序代码更改时,供应商块散列也会发生变化。想要从供应商块中提取webpack-runtime并将其放入另一个条目块' main'
entry: {
// entry point for vendor chunk and main chunk
vendor: ['react', 'react-redux', 'react-dom',
'universal-router', 'react-visibility-sensor', 'memoizee'],
main: './client.js'
},
output: {
filename: DEBUG ? '[name].js?[chunkhash]' : '[name].[chunkhash].js',
chunkFilename: DEBUG ? '[name].[id].js?[chunkhash]' : '[name].[id].[chunkhash].js',
},
target: 'web'
// Emit a file with assets paths
// https://github.com/sporto/assets-webpack-plugin#options
new AssetsPlugin({
path: path.resolve(__dirname, '../build'),
filename: 'assets.js',
processOutput: x => `module.exports = ${JSON.stringify(x)};`,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
// create a additional chunk for the common modules
// which is loaded in parallel to the requested chunks.
// name the chunks whose common chunk need to be created
chunks: ['main', 'Home'],
async: false
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
// min number of chunks that are requesting the vendor module
minChunks: 2
}),