refine
parent
1c0ebeda26
commit
c448d8d52a
|
@ -48,7 +48,8 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||||
}),
|
}),
|
||||||
// extract css into its own file
|
// extract css into its own file
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: utils.assetsPath('css/[name].[chunkhash].css'),
|
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
|
||||||
|
chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css'),
|
||||||
}),
|
}),
|
||||||
// Compress extracted CSS. We are using this plugin so that possible
|
// Compress extracted CSS. We are using this plugin so that possible
|
||||||
// duplicated CSS from different components can be deduped.
|
// duplicated CSS from different components can be deduped.
|
||||||
|
@ -81,7 +82,7 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||||
// https://github.com/kangax/html-minifier#options-quick-reference
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||||
},
|
},
|
||||||
// necessary to consistently work with multiple chunks
|
// necessary to consistently work with multiple chunks
|
||||||
chunksSortMode: 'dependency'
|
chunksSortMode: 'none'
|
||||||
}),
|
}),
|
||||||
// keep module.id stable when vender modules does not change
|
// keep module.id stable when vender modules does not change
|
||||||
new webpack.HashedModuleIdsPlugin(),
|
new webpack.HashedModuleIdsPlugin(),
|
||||||
|
@ -92,11 +93,8 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||||
ignore: ['.*']
|
ignore: ['.*']
|
||||||
}])
|
}])
|
||||||
],
|
],
|
||||||
|
// recordsPath: path.join(__dirname, 'records.json'),
|
||||||
optimization: {
|
optimization: {
|
||||||
splitChunks: {
|
|
||||||
chunks: 'all',
|
|
||||||
name: 'vendors',
|
|
||||||
},
|
|
||||||
runtimeChunk: 'single',
|
runtimeChunk: 'single',
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new UglifyJsPlugin({
|
new UglifyJsPlugin({
|
||||||
|
@ -130,9 +128,23 @@ if (config.build.productionGzip) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.build.bundleAnalyzerReport) {
|
if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) {
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
|
||||||
|
if (config.build.bundleAnalyzerReport) {
|
||||||
|
webpackConfig.plugins.push(new BundleAnalyzerPlugin({
|
||||||
|
analyzerPort: 8080,
|
||||||
|
generateStatsFile: false
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.build.generateAnalyzerReport) {
|
||||||
|
webpackConfig.plugins.push(new BundleAnalyzerPlugin({
|
||||||
|
analyzerMode: 'static',
|
||||||
|
openAnalyzer: false
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = webpackConfig
|
module.exports = webpackConfig
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ module.exports = {
|
||||||
|
|
||||||
productionSourceMap: false,
|
productionSourceMap: false,
|
||||||
// https://webpack.js.org/configuration/devtool/#production
|
// https://webpack.js.org/configuration/devtool/#production
|
||||||
devtool: '#source-map',
|
devtool: '#ource-map',
|
||||||
|
|
||||||
// Gzip off by default as many popular static hosts such as
|
// Gzip off by default as many popular static hosts such as
|
||||||
// Surge or Netlify already gzip all static assets for you.
|
// Surge or Netlify already gzip all static assets for you.
|
||||||
|
@ -84,6 +84,7 @@ module.exports = {
|
||||||
// View the bundle analyzer report after build finishes:
|
// View the bundle analyzer report after build finishes:
|
||||||
// `npm run build --report`
|
// `npm run build --report`
|
||||||
// Set to `true` or `false` to always turn it on or off
|
// Set to `true` or `false` to always turn it on or off
|
||||||
bundleAnalyzerReport: process.env.npm_config_report
|
bundleAnalyzerReport: process.env.npm_config_report || false,
|
||||||
|
generateAnalyzerReport: process.env.npm_config_generate_report || false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue