最新版公众号前端
This commit is contained in:
95
vue.config.js
Normal file
95
vue.config.js
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
// 优化配置:结合压缩和代码拆分,提高页面访问速度
|
||||
const path = require("path");
|
||||
const CompressionPlugin = require('compression-webpack-plugin');
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir);
|
||||
}
|
||||
module.exports = {
|
||||
// lintOnSave: false,
|
||||
lintOnSave: true,
|
||||
parallel: true, // 启用并行编译
|
||||
productionSourceMap: false, // 禁用生产环境 source map,减少构建体积,提高页面加载速度
|
||||
// 合并配置:gzip压缩 + 代码拆分
|
||||
configureWebpack: {
|
||||
// 只在开发环境使用source map,生产环境不使用
|
||||
devtool: process.env.NODE_ENV === 'development' ? 'eval-cheap-module-source-map' : false,
|
||||
plugins: [
|
||||
new CompressionPlugin({
|
||||
algorithm: 'gzip',
|
||||
test: /\.(js|css|html)$/,
|
||||
threshold: 10240,
|
||||
minRatio: 0.8
|
||||
})
|
||||
],
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
// 拆分 echarts 库
|
||||
echarts: {
|
||||
name: 'chunk-echarts',
|
||||
test: /[\\/]node_modules[\\/]echarts[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 其他第三方库
|
||||
// 拆分 quill 富文本编辑器
|
||||
quill: {
|
||||
name: 'chunk-quill',
|
||||
test: /[\\/]node_modules[\\/]quill[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 拆分 pdf 相关库
|
||||
pdf: {
|
||||
name: 'chunk-pdf',
|
||||
test: /[\\/]node_modules[\\/](pdfh5|vue-pdf)[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 拆分 高德地图
|
||||
amap: {
|
||||
name: 'chunk-amap',
|
||||
test: /[\\/]node_modules[\\/]vue-amap[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 拆分 canvas 相关库
|
||||
canvas: {
|
||||
name: 'chunk-canvas',
|
||||
test: /[\\/]node_modules[\\/](canvas|dommatrix)[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 拆分 微信 SDK
|
||||
weixin: {
|
||||
name: 'chunk-weixin',
|
||||
test: /[\\/]node_modules[\\/]weixin-js-sdk[\\/]/,
|
||||
priority: 20,
|
||||
chunks: 'all'
|
||||
},
|
||||
// 其他第三方库
|
||||
vendors: {
|
||||
name: 'chunk-vendors',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
chainWebpack: (config) => {
|
||||
config.resolve.alias
|
||||
.set("@$", resolve("src"))
|
||||
.set("assets", resolve("src/assets"))
|
||||
.set("components", resolve("src/components"))
|
||||
.set("layout", resolve("src/layout"))
|
||||
.set("base", resolve("src/base"))
|
||||
.set("static", resolve("src/static"));
|
||||
},
|
||||
|
||||
publicPath: "./",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user