1
This commit is contained in:
42
vue.config.js
Normal file
42
vue.config.js
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
var webpack = require('webpack')
|
||||
|
||||
module.exports = {
|
||||
chainWebpack(config) {
|
||||
// scss全局变量
|
||||
const oneOfsMap = config.module.rule('scss').oneOfs.store
|
||||
oneOfsMap.forEach((item) => {
|
||||
item
|
||||
.use('sass-resources-loader')
|
||||
.loader('sass-resources-loader')
|
||||
.options({
|
||||
// 引入一个全局sass文件
|
||||
resources: ['./src/styles/variables.scss'],
|
||||
})
|
||||
.end()
|
||||
})
|
||||
|
||||
// 忽略 moment.js 的 locale 文件,减小体积
|
||||
config.plugin('ignore')
|
||||
.use(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)); //忽略/moment/locale下的所有文件
|
||||
|
||||
// 生产环境优化
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
// 代码压缩 - 移除 console 和 debugger
|
||||
config.optimization
|
||||
.minimize(true)
|
||||
.minimizer('terser')
|
||||
.tap(args => {
|
||||
if (args[0] && args[0].terserOptions) {
|
||||
args[0].terserOptions.compress = {
|
||||
...args[0].terserOptions.compress,
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
pure_funcs: ['console.log', 'console.info', 'console.debug']
|
||||
}
|
||||
}
|
||||
return args
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user