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/api",
        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: {
          __Home: ["./src/views/Home.vue"],
          __SignIn: ["./src/views/SignIn.vue"],
          // __category: ["./src/views/category/Index.vue"],
          __recycleBin: ["./src/views/category/recycleBin.vue"],
          __templateManagement: ["./src/views/category/templateManagement.vue"],
          __tracingManagement: ["./src/views/category/tracingManagement/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",
          ],
          __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",
            "./src/views/userCenter/SetPassword/index.vue",
            "./src/views/userCenter/CompanyVerify/index.vue",
            "./src/views/userCenter/EditPassword/index.vue",
            "./src/views/userCenter/EditPhone/index.vue",
            "./src/views/userCenter/PersonVerify/index.vue",
          ],
          __editTemplate: ["./src/views/editTemplate/index.vue"],
          // __copyrightApplication: [
          //   "./src/views/copyrightApplication/index.vue",
          // ],
          __PassMaker: ["./src/views/Collection/PassMaker/index.vue"],
        },
      },
    },
  },
});
