mirror of
https://github.com/TangSengDaoDao/TangSengDaoDaoWeb
synced 2025-06-01 14:32:51 +00:00
fix: 🐛修复TerserPlugin编译报错
This commit is contained in:
parent
13fed127d7
commit
cadc4e5220
@ -1,70 +1,40 @@
|
||||
var path = require('path')
|
||||
|
||||
const { override, babelInclude, addWebpackPlugin } = require('customize-cra')
|
||||
const { override, babelInclude, addWebpackPlugin, overrideDevServer } = require('customize-cra')
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
// module.exports = override(
|
||||
// // 注意是production环境启动该plugin
|
||||
// process.env.NODE_ENV === 'production' && addWebpackPlugin(
|
||||
// new UglifyJsPlugin({
|
||||
// // 开启打包缓存
|
||||
// cache: true,
|
||||
// // 开启多线程打包
|
||||
// parallel: true,
|
||||
// uglifyOptions: {
|
||||
// // 删除警告
|
||||
// warnings: false,
|
||||
// // 压缩
|
||||
// compress: {
|
||||
// // 移除console
|
||||
// drop_console: true,
|
||||
// // 移除debugger
|
||||
// drop_debugger: true
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// )
|
||||
// )
|
||||
const addDevServerConfig = () => config => {
|
||||
return {
|
||||
...config,
|
||||
client: {
|
||||
overlay: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function (config, env) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
config.devtool = false;
|
||||
}
|
||||
if (env === 'production') {
|
||||
config.optimization = {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin()],
|
||||
};
|
||||
}
|
||||
return Object.assign(
|
||||
config,
|
||||
override(
|
||||
// 判断环境变量ANALYZER参数的值
|
||||
process.env.ANALYZER && addWebpackPlugin(new BundleAnalyzerPlugin()),
|
||||
// process.env.NODE_ENV === 'production' && addWebpackPlugin(
|
||||
// new UglifyJsPlugin({
|
||||
// cache: true,
|
||||
// // 开启多线程打包
|
||||
// parallel: true,
|
||||
// uglifyOptions: {
|
||||
// // 删除警告
|
||||
// warnings: false,
|
||||
// // 压缩
|
||||
// compress: {
|
||||
// // 移除console
|
||||
// drop_console: true,
|
||||
// // 移除debugger
|
||||
// drop_debugger: true
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
// ),
|
||||
babelInclude([
|
||||
/* transpile (converting to es5) code in src/ and shared component library */
|
||||
path.resolve('src'),
|
||||
path.resolve('../../packages'),
|
||||
])
|
||||
)(config, env)
|
||||
)
|
||||
module.exports = {
|
||||
webpack: function (config, env) {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
config.devtool = false;
|
||||
}
|
||||
if (env === 'production') {
|
||||
config.optimization = {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin()],
|
||||
};
|
||||
}
|
||||
return Object.assign(
|
||||
config,
|
||||
override(
|
||||
// 判断环境变量ANALYZER参数的值
|
||||
process.env.ANALYZER && addWebpackPlugin(new BundleAnalyzerPlugin()),
|
||||
babelInclude([
|
||||
/* transpile (converting to es5) code in src/ and shared component library */
|
||||
path.resolve('src'),
|
||||
path.resolve('../../packages'),
|
||||
])
|
||||
)(config, env)
|
||||
)
|
||||
},
|
||||
devServer: overrideDevServer(addDevServerConfig())
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user