Commit e1c29074 authored by lipengcheng 's avatar lipengcheng

feat(vue.config.js): 优化打包去掉console配置

parent 290cf4a6
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"lodash-webpack-plugin": "^0.11.5", "lodash-webpack-plugin": "^0.11.5",
"moment": "^2.27.0",
"register-service-worker": "^1.7.1", "register-service-worker": "^1.7.1",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-bus": "^1.2.1", "vue-bus": "^1.2.1",
......
...@@ -22,17 +22,15 @@ module.exports = { ...@@ -22,17 +22,15 @@ module.exports = {
} }
}, },
chainWebpack: (config) => { chainWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// 按需引入lodash
config.plugin('lodashReplace').use(new LodashModuleReplacementPlugin())
// 生产环境打包去掉console
config.when(process.env.NODE_ENV !== 'development', (config) => { config.when(process.env.NODE_ENV !== 'development', (config) => {
// 生产环境打包去掉console
config.optimization.minimizer('terser').tap((options) => { config.optimization.minimizer('terser').tap((options) => {
options[0].terserOptions.compress.drop_console = true options[0].terserOptions.compress.drop_console = true
return options return options
}) })
// 按需引入lodash
config.plugin('lodashReplace').use(new LodashModuleReplacementPlugin())
}) })
}
config.module config.module
.rule('eslint') .rule('eslint')
.use('eslint-loader') .use('eslint-loader')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment