vue2 打包文件配置
在项目的根目录中创建webpack.config.js文件
配置webpack.config.js文件,如下代码
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
// 项目部署的基本路径,默认 "/"
publicPath: './',
// 项目打包的根目录,默认 "dist"
outputDir: "dist",
// 项目打包的静态资源存放目录,默认 ""
assetsDir: "static",
// 项目打包的index.html输出路径,默认 "index.html"
indexPath: "index.html",
// 多页应用配置参数,默认 undefined
pages: undefined,
// 开发环境 eslint 异常信息提示位置,默认 "default" 在浏览器窗口提示,为 true 在控制台提示
lintOnSave: process.env.NODE_ENV === 'development',
// 项目打包是否生成js的 source map 调试包,默认 true,生产部署设置为false
productionSourceMap: false,
//跨域配置
devServer: {
proxy: {
'/api': { // 被代理的接口名
target:'', //要跨域的域名
changeOrigin: true, //是否开启跨域
pathRewrite: {
'^/api': '',
},
}
}
},
transpileDependencies: true,
});
注:该文档为个人理解所写,有误可建议修改

浙公网安备 33010602011771号