vue.config.js 1.95 KB
/*
 * @Author: your name
 * @Date: 2021-12-24 14:16:06
 * @LastEditTime: 2022-02-14 15:02:53
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /sdc-face/API20211215/vue.config.js
 */
const CopyWebpackPlugin = require("copy-webpack-plugin") //引入插件
module.exports  = {
  outputDir:process.env.outputDir || 'dist',
  productionSourceMap: false,
  lintOnSave: false,
  publicPath: "./",
  // 由于浏览器有跨域限制,这里cli 工具提供了 启动本地代理服务器 请求
  devServer:{
      open:false,      // 是否打开浏览器;
      hotOnly:true,    // 是否热更新;

      proxy:{
          '/SDCAPI':{   // 路径中有 /api 的请求都会走这个代理 , 可以自己定义一个,下面移除即可
              // target:'http://huayan.320.io/',    // 目标代理接口地址,实际跨域要访问的接口,这个地址会替换掉 axios.defaults.baseURL
              target:'http://3d1576a219.wicp.vip/',
              secure:false,
              changeOrigin:true,  // 开启代理,在本地创建一个虚拟服务端
              ws:true,       // 是否启用  websockets;
              pathRewrite:{   // 去掉 路径中的  /api  的这一截
                  '^/api':''
              }
          },

          '/test':{
              target:'http://v.juhe.cn/joke',   // 目标代理接口地址,实际跨域要访问的接口,这个地址会替换掉 axios.defaults.baseURL
              secure:false,
              changeOrigin:true,
              ws:true,
              pathRewrite:{
                  '^/test':'',
              }
          }
      
      },

  },
  configureWebpack: {
    plugins: [
      new CopyWebpackPlugin([ //打包时执行拷贝
        {
          from: __dirname + "/public/config/js/config.js",
          to:   __dirname + "/dist/config/js/config.js"
        }
      ])
    ]
  },

}