const TerserPlugin = require('terser-webpack-plugin'); const Timestamp = new Date().getTime(); module.exports = { devServer: { host: '127.1.1.88', },
productionSourceMap: false,
publicPath: '/migratory/',
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// 返回一个将会被合并的对象
return {
optimization: {
minimizer: [
new TerserPlugin({
sourceMap: false,
terserOptions: {
compress: {
drop_console: true
}
}
})
]
},
output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
filename: `js/[name].[chunkhash].${Timestamp}.js`,
chunkFilename: `js/[name].[chunkhash].${Timestamp}.js`,
},
}
};
},
outputDir: 'migratory',
assetsDir: undefined,
runtimeCompiler: undefined,
parallel: undefined,
css: undefined
}
来源:oschina
链接:https://my.oschina.net/u/2428630/blog/4299714