import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import ElementPlus from "unplugin-element-plus/vite";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    ElementPlus({
      // options
    }),
  ],
  resolve: {
    alias: {
      // vue: resolve(`./node_modules/vue`),
      "@": resolve("./src"),
    },
  },
  server: {
    proxy: {
      "^/api": {
        target: "http://183.134.99.140:46790/",
        // target: "http://121.37.141.165:46790/",
        // target: "https://sy.8n.cn",
        changeOrigin: true,
      },
      "^/proxyPdf": {
        target:
          "https://zbzb.s3.ap-northeast-1.amazonaws.com/yuan.org/ycc/white-paper/zh.pdf",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/proxyPdf/, ""),
      },
    },
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          __SignIn: ["./src/views/SignIn.vue"],
          __recycleBin: ["./src/views/RecycleBin/index.vue"],
          __templateManagement: ["./src/views/TemplateManagement/index.vue"],
          __tracingDetail: ["./src/views/Tracing/tracingDetail/index.vue"],
          __tracingManagement: [
            "./src/views/Tracing/tracingManagement/index.vue",
          ],
          __editTemplate: ["./src/views/editTemplate/index.vue"],
          // __copyrightManagement: ["./src/views/copyrightManagement/index.vue"],
          // __draftBox: ["./src/views/draftBox/index.vue"],
          __CollectionManagement: [
            "./src/views/Collection/CollectionManagement/index.vue",
          ],
          __AlbumManagement: [
            "./src/views/Collection/AlbumManagement/index.vue",
          ],
          __issuedBatchesDetail: [
            "./src/views/Collection/IssuedBatchesDetail/index.vue",
          ],
          __AlbumDetail: ["./src/views/Collection/AlbumDetail/index.vue"],
          __TransferRecords: [
            "./src/views/Collection/TransferRecords/index.vue",
          ],
          __userCenter: [
            "./src/views/userCenter/index.vue",
            "./src/views/userCenter/choosePackage/index.vue",
          ],
          // __copyrightApplication: [
          //   "./src/views/copyrightApplication/index.vue",
          // ],
          __PassMaker: ["./src/views/Collection/PassMaker/index.vue"],
        },
      },
    },
  },
});
