import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import { resolve } from "path"; import ElementPlus from "unplugin-element-plus/vite"; let app = "fire"; if (process.argv.length > 3) { app = process.argv[process.argv.length - 1].trim(); } const dev = true; const devUrl = "https://xj-mix3d.4dkankan.com" // const devUrl = "https://192.168.0.25" export default defineConfig({ define: { VITE_APP_APP: JSON.stringify(app), }, base: "./", build: { rollupOptions: { input: { index: resolve(__dirname, "index.html"), map: resolve(__dirname, "map.html"), mirror: resolve(__dirname, "mirror.html"), // 在这里继续添加更多页面 }, }, outDir: `dist/${app}`, }, resolve: { alias: [ { find: "@", replacement: resolve(__dirname, "./src"), }, ], }, plugins: [ vue(), ElementPlus({ useSource: true, }), ], server: { port: 5173, host: "0.0.0.0", proxy: { "/api": { secure: false, target: dev ? devUrl : "mix3d.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/api`), ""), }, "/fusion-xj": { secure: false, target: dev ? devUrl : "mix3d.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion-xj"), }, "/dev-code": { // target: "https://localhost:7173/", target: dev ? "https://xj-mix3d.4dkankan.com/code" : "https://mix3d.4dkankan.com/code", changeOrigin: true, secure: false, rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""), }, "/swkk": { target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""), }, "/service": { target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com", changeOrigin: true, }, "/swss": { target: dev ? "https://uat-laser.4dkankan.com/uat" : "https://laser.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/swss`), ""), }, "/laser": { target: dev ? "https://uat-laser.4dkankan.com" : "https://laser.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"), }, "/fdkk": { target: dev ? "https://uat-laser.4dkankan.com/uat" : "https://laser.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/fdkk`), "/fdkk"), }, }, }, });