cygnal/build/webpack.prod.conf.js

32 lines
917 B
JavaScript
Raw Permalink Normal View History

2018-06-25 18:29:57 +02:00
'use strict'
const webpack = require('webpack')
const merge = require('webpack-merge')
process.env.NODE_ENV = 'production';
2018-06-25 18:29:57 +02:00
const baseWebpackConfig = require('./webpack.base.conf')
const env = require('../config/prod.env')
const utils = require('./utils')
2018-06-25 18:29:57 +02:00
const webpackConfig = merge(baseWebpackConfig, {
mode: 'production',
2018-07-11 02:43:14 +02:00
output: {
filename: utils.assetsPath('js/[name].[chunkhash:4].js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash:4].js'),
2018-07-11 02:43:14 +02:00
},
plugins: [
new webpack.DefinePlugin({
'process.env': env,
2018-07-11 02:43:14 +02:00
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
]
2018-06-25 18:29:57 +02:00
})
if (process.env.ANALYZE) {
2018-07-11 02:43:14 +02:00
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
2018-06-25 18:29:57 +02:00
}
module.exports = webpackConfig