/*
 * @Author: lixg lixg@dongwu-inc.com
 * @Date: 2023-01-13 11:42:48
 * @LastEditors: lixg lixg@dongwu-inc.com
 * @LastEditTime: 2023-03-10 11:42:51
 * @FilePath: /stu_h5/vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {defineConfig, loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
import legacy from "@vitejs/plugin-legacy";
import topLevelAwait from "vite-plugin-top-level-await";

import {viteMockServe} from "vite-plugin-mock";

const path = require("path");

export default defineConfig(({ command, mode }) =>
  ({
    host: "192.158.3.51",
    base: loadEnv(mode, process.cwd()).VITE_BASE,
    build: {
      outDir: loadEnv(mode, process.cwd()).VITE_OUTPUT_DIR,
    },
    plugins: [
      vue(),
      legacy({
        targets: ["chrome 52", "defaults", "not IE 11"]
      }),
      // viteMockServe({
      //     mockPath: './src/mock/mocks',
      // })
      topLevelAwait({
        promiseExportName: "__tla",
        promiseImportName: i => `__tla_${i}`
      }),
    ],
    resolve: {
      alias: [
        { find: "@", replacement: path.resolve(__dirname, "src") }
      ]
    },
    server: {
      host: "192.168.3.51",
      proxy: {
        "/file/upload": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/file/img": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/stu": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/queryVoteSubmitDetailById": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/work": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/discuss": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/discussSubmit": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/comment": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/vote": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/admin": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/activity": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/liveBroadcast": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/examination": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/assessment": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/workSubmit": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/userbasic": {
          target: "https://u-pre.boe.com",
          changeOrigin: true,
        }, "/link": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/onlineClasses/queryOnlineClassesStudyDetail": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/evaluation/queryEvaluationDetailById": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/external/exam/queryExternalExam": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/evaluation/evaluationToLearn": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/evaluation/queryEvaluationTaskStatusOne": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/statement/add": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/collection": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/delete": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/praise": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/update": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/list": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/stu/externalExam/submitExternalExam": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/comment/list": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/comment/add": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/comment/praise": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/comment/collection": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/info": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/getComments": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        }, "/statement/getMoreComments": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },
        "/voteSubmit": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY_URL,
          changeOrigin: true,
        },

      }
    }
  })
);
