import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import { resolve } from "path"; import ElementPlus from "unplugin-element-plus/vite"; import WindiCSS from 'vite-plugin-windicss' import legacy from '@vitejs/plugin-legacy'; let app = "criminal"; if (process.argv.length > 3) { app = process.argv[process.argv.length - 1].trim(); } const dev = true; export default defineConfig({ define: { VITE_APP_APP: JSON.stringify(app), }, base: "./", build: { outDir: `dist/${app}`, }, resolve: { alias: [ { find: "@", replacement: resolve(__dirname, "./src"), }, ], }, css: { preprocessorOptions: { scss: { additionalData: `@use "@/app/${app}/useStyle.scss" as *;`, }, }, }, plugins: [ vue(), WindiCSS(), ElementPlus({ useSource: true, }), // legacy({ // targets: ['chrome 52'], // 需要兼容的目标列表,可以设置多个 // additionalLegacyPolyfills: ['regenerator-runtime/runtime'], // 面向IE11时需要此插件 // }), ], server: { port: 5173, host: "0.0.0.0", proxy: { "/api": { target: dev ? "http://192.168.0.55:8808" : "mix3d.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/api`), ""), }, "/fusion": { target: dev ? "http://192.168.0.55:8808" : "mix3d.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"), }, "/dev-code": { // target: "http://192.168.9.171:9200", target: dev ? "https://test-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 ? "http://192.168.0.55" : "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"), }, "/v3": { target: dev ? "https://restapi.amap.com" : "https://laser.4dkankan.com", changeOrigin: true, rewrite: (path) => path.replace(new RegExp(`^/swss`), ""), }, }, }, });