const { defineConfig } = require("@vue/cli-service");
const path = require("path");
module.exports = defineConfig({
publicPath: `/${process.env.VUE_APP_PROJECT_PREFIX}/`, // 默认静态资源路径
outputDir: "dist", // 打包完毕文件夹名
assetsDir: "static", // 放置静态资源的目录
lintOnSave: false, // 保存代码不进行eslint检测
productionSourceMap: false, // 生产环境无需source map
transpileDependencies: true,
chainWebpack: (config) => {
config.resolve.alias.set("@", path.join(__dirname, "src"));
config.plugin("html").tap((args) => {
args[0].title = "通行费与油品销售定价辅助决策平台";
return args;
});
// 生产环境代码压缩
if (process.env.NODE_ENV === "production") {
config.output.filename("./js/[name].[chunkhash:8].js");
config.output.chunkFilename("./js/[name].[chunkhash:8].js");
config.optimization
.minimize(true)
.minimizer("terser")
.tap((args) => {
let { terserOptions } = args[0];
terserOptions.compress.drop_console = true;
terserOptions.compress.drop_debugger = true;
return args;
});
config.optimization.splitChunks({
cacheGroups: {
common: {
name: "common",
chunks: "all",
minSize: 1,
minChunks: 2,
priority: 1,
},
vendor: {
name: "chunk-libs",
chunks: "all",
test: /[\\/]node_modules[\\/]/,
priority: 10,
},
},
});
}
},
// 跨域配置
devServer: {
open: true,
host: "0.0.0.0",
port: 9090,
proxy: {
"/api": {
//代理的baseUrl(这里的地址需要更改)
// target: "http://10.101.10.10:10010/",
changeOrigin: true,
secure: true,
pathRewrite: {
"^/api": "",
},
},
},
},
});
webpack的配置文件
于 2023-01-28 16:44:16 首次发布