module.exports = {
publicPath: './', //公共路径,影响打包生成文件的引入资源的公共路径
devServer: { //本地服务器配置
port: 8980, //端口
host: 'localhost', //域名
https: false, //是否启用https
open: true, //是否在编译完成之后自动打开浏览器访问
//代理解决跨域
proxy: {
'/byProxy': { // 匹配所有以 '/api1'开头的请求路径
target: 'http://localhost:8980',// 代理目标的基础路径
changeOrigin: true,
changeOrigin: true,
pathRewrite: { '^/api1': '' }
},
'/byProxy2': { // 匹配所有以 '/api2'开头的请求路径
target: 'http://localhost:8980',// 代理目标的基础路径
changeOrigin: true,
pathRewrite: { '^/api2': '' }
}
}
},
lintOnSave: false, // lint语法检测
outputDir: 'dist', //打包输出目录
assetsDir: 'assets', //静态文件输出目录(基于dist)
// prodectionSourceMap: true, //取消.map文件的打包,加快打包速度
configureWebpack: config => {
// process.env为环境变量,分别对应.env.development文件和.env.production文件 此处表示加快开发环境打包速度
if (process.env.NODE_ENV !== 'production') return;
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true; //生产环境去掉console.log
return { // 此处配置webpack.config.js的相关配置
plugins: [],
performance: {}
};
}
}
vue.config.js常用配置
最新推荐文章于 2025-04-03 00:00:00 发布