mooncake-cli
Version:
59 lines (50 loc) • 1.28 kB
JavaScript
const Merge = require('webpack-merge')
const WebpackParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')
const cleanPack = require('clean-webpack-plugin')
const basicConfig = require('./pack.basic.js')
const {resolvePath, getBuildEntry, pagePath} = require('./tool.js')
const prodConfig = {
entry: getBuildEntry(pagePath),
mode: 'production',
output: {
path: resolvePath('build'),
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/', //cdn
},
plugins: [
new cleanPack(['build'], {
root: process.cwd(), //根目录
verbose: true, //开启在控制台输出信息
dry: false //启用删除文件
}),
new WebpackParallelUglifyPlugin({
uglifyJS: {
output: {
beautify: false,
comments: false
},
compress: {
warnings: false,
drop_console: true,
collapse_vars: true,
reduce_vars: true
}
}
})
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
chunks: 'initial',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
}
}
}
}
}
module.exports = Merge(basicConfig, prodConfig)