import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import styleImport from "vite-plugin-style-import"; import { resolve } from "path"; const pathResolve = (dir) => { return resolve(__dirname, ".", dir); }; const alias = { "@": pathResolve("./src/"), "@tools": pathResolve("./src/tools"), "@api": pathResolve("./src/api"), "@com": pathResolve("./src/components"), "/@": pathResolve("./src/"), }; // https://vitejs.dev/config/ export default defineConfig({ base: process.env.ELECTRON == "true" ? "./" : "./", resolve: { alias }, optimizeDeps: { include: ["element-plus/lib/locale/lang/zh-cn"], }, plugins: [vue()], server: { port: "3002", host: "0.0.0.0", open: false, //自动打开 base: "./ ", //生产环境路径 proxy: { // 本地开发环境通过代理实现跨域,生产环境使用 nginx 转发 // 正则表达式写法 "^/sharding": { // target: 'http://wanghs.nat300.top', target: "http://10.81.3.154:6015", // target: "http://192.168.1.108:6015", changeOrigin: true, //开启代理 rewrite: (path) => path.replace(/^\/sharding/, ""), }, "^/adapter": { target: "http://123.60.219.66:8011", // target: 'http://wanghs.nat300.top', changeOrigin: true, //开启代理 rewrite: (path) => path.replace(/^\/adapter/, ""), }, "^/custom": { target: "http://123.60.219.66:8060", // target: 'http://wanghs.nat300.top', changeOrigin: true, //开启代理 rewrite: (path) => path.replace(/^\/custom/, ""), }, "^/windturbine": { target: "http://123.60.219.66:8071", // target: 'http://wanghs.nat300.top', changeOrigin: true, //开启代理 rewrite: (path) => path.replace(/^\/windturbine/, ""), }, "^/scadas": { target: "http://123.60.219.66:8072", // target: 'http://wanghs.nat300.top', changeOrigin: true, //开启代理 rewrite: (path) => path.replace(/^\/scadas/, ""), }, }, }, });