1 Star 0 Fork 1

邀月诗韵/webprototype-web

forked from rabbit/webprototype-web 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
ZhenNan.Shi 提交于 2022-01-04 14:22 . 🎉 first commit
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const env = process.env.NODE_ENV;
const isProduction = env === "production";
const publicPath = isProduction ? "/" : "/";
// 公共代码抽离
function splitChunks(config) {
config.optimization = {
splitChunks: {
cacheGroups: {
vendor: {
chunks: "all",
test: /node_modules/,
name: "vendor",
minChunks: 1,
maxInitialRequests: 5,
minSize: 0,
priority: 100
},
common: {
chunks: "all",
test: /[\\/]src[\\/]js[\\/]/,
name: "common",
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
priority: 60
},
styles: {
name: "styles",
test: /\.(sa|sc|c|le)ss$/,
chunks: "all",
enforce: true
},
runtimeChunk: {
name: "manifest"
}
}
}
};
}
// 代码压缩
function uglifyJs(config) {
config.plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
compress: {
drop_debugger: true,
drop_console: true,
pure_funcs: ["console.log"]
}
},
sourceMap: false,
parallel: true
})
);
}
module.exports = {
publicPath,
assetsDir:'static',
lintOnSave: false,
productionSourceMap: false,
runtimeCompiler: true,
devServer: {
open: true,
host: "0.0.0.0",
port: 8000,
proxy: {
[process.env.VUE_APP_BASE_API]: {
target: `http://10.10.14.27:80`, // 内网
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: ""
}
}
}
},
css: {
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true
}
}
}
},
configureWebpack: (config) => {
if (isProduction) {
// 为生产环境修改配置...
config.mode = "production";
config["performance"] = {
//打包文件大小配置
maxEntrypointSize: 10000000,
maxAssetSize: 30000000
};
// 公共代码抽离
splitChunks(config);
// 代码压缩
uglifyJs(config);
}
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/null_202_6777/webprototype-web.git
git@gitee.com:null_202_6777/webprototype-web.git
null_202_6777
webprototype-web
webprototype-web
master

搜索帮助