import { fileURLToPath, URL } from "node:url"; import { defineConfig, loadEnv } from "vite"; import createVitePlugins from "./build/plugins"; import Components from "unplugin-vue-components/vite"; import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; export default defineConfig(({ mode }) => { // eslint-disable-next-line node/prefer-global/process const env = loadEnv(mode, process.cwd(), ""); return { base: "./", // 让 CSS 文件路径正确 ssr: { noExternal: ["some-package"], // 确保 CSS 相关的库不会被 SSR 处理 }, plugins: [ createVitePlugins(env), Components({ resolvers: [ElementPlusResolver()], }), ], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), "@iconify-icons": "/node_modules/@iconify-icons", // 设置正确的路径 }, }, server: { host: "0.0.0.0", proxy: { "/api": { target: env.VITE_BASE_URL, changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ""), }, // 未知量 //振动、激光测距仪 "/WZLapi": { target: "http://192.168.50.241:9001", // WZLapi 目标地址 // target: "http://106.120.102.238:18080/WindTransDev", // WZLapi 外网目标地址 changeOrigin: true, rewrite: (path) => path.replace(/^\/WZLapi/, ""), }, }, css: { preprocessorOptions: { scss: { api: "modern-compiler", }, }, }, }, }; });