performance optimization
Former-commit-id: 2b6ff62544b71078714b4f0a1f465941829910ea Former-commit-id: 5dc98ee77f03ce3a617ad6efdbee45568db0d941 Former-commit-id: 279188c012ccccd7545f1c7ef9ad583ebc94f877 Former-commit-id: 983a49cae179740f17e70de6edef8509ec441ca3 [formerly fba357218d2f2e29d45b0fd398d57369d258757f] Former-commit-id: 604878fbd93447f6e7a229cdf6b3524144d43ce8 Former-commit-id: ea4788ebb0f14bb63a6b8aaa48b6918efd89a9d0 Former-commit-id: 8a6dc6b6daccdb9a2699a68e927f80d06d21aff5 Former-commit-id: 6e2317d25d5b1794cb8404c181b6a38ee598892a Former-commit-id: ac9cd70286571f2026120ace77ce36a0e0667f9a
This commit is contained in:
@@ -8,8 +8,8 @@ module.exports = {
|
||||
'@vue/standard'
|
||||
],
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
|
||||
'no-console': 'off',
|
||||
'no-debugger': 'off'
|
||||
},
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
|
||||
@@ -37,12 +37,55 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
configureWebpack: {
|
||||
// 关闭文件过大提示,利于打包加快速度
|
||||
performance: {
|
||||
hints: 'warning',
|
||||
// 入口起点的最大体积
|
||||
maxEntrypointSize: 50000000,
|
||||
// 生成文件的最大体积
|
||||
maxAssetSize: 30000000,
|
||||
// 只给出 js 文件的性能提示
|
||||
assetFilter: function(assetFilename) {
|
||||
return assetFilename.endsWith('.js');
|
||||
}
|
||||
},
|
||||
// 公共代码抽离和代码分割
|
||||
optimization: {
|
||||
runtimeChunk: 'single',
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendors: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: 'vendors',
|
||||
minSize: 30000,
|
||||
minChunks: 1,
|
||||
chunks: 'initial',
|
||||
priority: 1 // 设置处理的优先级,数值越大越优先处理
|
||||
},
|
||||
commons: {
|
||||
test: /[\\/]src[\\/]common[\\/]/,
|
||||
name: 'commons',
|
||||
minSize: 30000,
|
||||
minChunks: 3,
|
||||
chunks: 'initial',
|
||||
priority: -1,
|
||||
reuseExistingChunk: true // 允许使用已经存在的代码块
|
||||
},
|
||||
styles: {
|
||||
name: 'styles',
|
||||
test: /\.(sa|sc|c)ss$/,
|
||||
chunks: 'all',
|
||||
enforce: true
|
||||
},
|
||||
runtimeChunk: {
|
||||
name: 'manifest'
|
||||
}
|
||||
}
|
||||
},
|
||||
minimizer: [
|
||||
// 自定义js优化配置,将会覆盖默认配置
|
||||
new UglifyJsPlugin({
|
||||
exclude: /\.min\.js$/, // 过滤掉以".min.js"结尾的文件,我们认为这个后缀本身就是已经压缩好的代码,没必要进行二次压缩
|
||||
exclude: /\.min\.js$/, // 过滤掉以 '.min.js' 结尾的文件,我们认为这个后缀本身就是已经压缩好的代码,没必要进行二次压缩
|
||||
cache: true,
|
||||
parallel: true, // 开启并行压缩,充分利用cpu
|
||||
sourceMap: false,
|
||||
@@ -50,7 +93,9 @@ module.exports = {
|
||||
uglifyOptions: {
|
||||
compress: {
|
||||
unused: true,
|
||||
drop_debugger: true
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
pure_funcs: ['console.log']
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
|
||||
Reference in New Issue
Block a user