const proxy = {
  "/api/ecs_core": {
    target: process.env.VUE_APP_CORE_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_exam_work": {
    target: process.env.VUE_APP_EXAM_WORK_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_outlet": {
    target: process.env.VUE_APP_EXCHANGE_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_ques": {
    target: process.env.VUE_APP_QUESTIONS_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_oe_admin": {
    target: process.env.VUE_APP_OE_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_oe_student": {
    target: process.env.VUE_APP_OE_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_marking": {
    target: process.env.VUE_APP_MARKING_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_data_process": {
    target: process.env.VUE_APP_DATA_PROCESS_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_prt": {
    target: process.env.VUE_APP_PRINT_HOST_URL,
    changeOrigin: true,
  },
  "/api/ctr/task": {
    target: process.env.VUE_APP_TASK_HOST_URL,
    changeOrigin: true,
  },
  "/api/ecs_reports": {
    target: process.env.VUE_APP_REPORTS_HOST_URL,
    changeOrigin: true,
  },
};

var webpack = require("webpack");
/** @type {import("@vue/cli-service").ProjectOptions} */
module.exports = {
  // 这里设置项目的路径，比如 '/admin' 。设置以后 BASE_URL就有值了。
  // 注意这解决不了CDN的问题，CDN的问题要另行研究。
  // 可能的方案是另设一个替代 BASE_URL 的环境变量解决 <%%= BASE_URL %%>favicon.ico 和 ${process.env.BASE_URL}service-worker.js
  publicPath: "/admin",
  lintOnSave: process.env.NODE_ENV !== "production" ? true : "error",
  devServer: {
    proxy,
  },
  configureWebpack: {
    // devtool: "source-map",  // for vscode debug
    plugins: [
      // Ignore all locale files of moment.js
      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
    ],
  },
  transpileDependencies: [
    /\bvue-awesome\b/,
    /\bvue-echarts\/components\b/,
    /\bresize-detector\b/,
  ],
};

require("events").EventEmitter.defaultMaxListeners = 0;
