4、vue.config.js 配置

132 阅读1分钟

1、devServe配置包含跨域配置

module.exports = {
  devServe: {
    port: 8888, //端口号
    open: true,//build自动打开浏览器
    // 跨域
    proxy: {
      "/api": {
        target: "",  //目标路径
        secure: false, // 如果是https接口,需要配置这个参数
        changeOrigin: true,//是否允许跨域
        pathRewrite: {
          "^/api": "",//重写路径空即可
        },
      },
    }
  },
};

2 全局配置

module.exports = {
  outputDir: "dist", // 构建好的文件输出到哪里
  assetsDir: "static", //静态资源打包地址
  // 是否在构建生产包时生成 sourceMap 文件,false将提高构建速度  映射文件 打包时使用
  productionSourceMap: false,
};