vite.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import styleImport from "vite-plugin-style-import";
  4. import { resolve } from "path";
  5. const pathResolve = (dir) => {
  6. return resolve(__dirname, ".", dir);
  7. };
  8. const alias = {
  9. "@": pathResolve("./src/"),
  10. "@tools": pathResolve("./src/tools"),
  11. "@api": pathResolve("./src/api"),
  12. "@com": pathResolve("./src/components"),
  13. "/@": pathResolve("./src/"),
  14. };
  15. // https://vitejs.dev/config/
  16. export default defineConfig({
  17. base: process.env.ELECTRON == "true" ? "./" : "./",
  18. resolve: { alias },
  19. optimizeDeps: {
  20. include: ["element-plus/lib/locale/lang/zh-cn"],
  21. },
  22. plugins: [vue()],
  23. server: {
  24. port: "3002",
  25. host: "0.0.0.0",
  26. open: false, //自动打开
  27. base: "./ ", //生产环境路径
  28. proxy: {
  29. // 本地开发环境通过代理实现跨域,生产环境使用 nginx 转发
  30. // 正则表达式写法
  31. "^/sharding": {
  32. // target: 'http://wanghs.nat300.top',
  33. target: "http://10.81.3.154:8075",
  34. changeOrigin: true, //开启代理
  35. rewrite: (path) => path.replace(/^\/sharding/, ""),
  36. },
  37. "^/adapter": {
  38. target: "http://123.60.219.66:8011",
  39. // target: 'http://wanghs.nat300.top',
  40. changeOrigin: true, //开启代理
  41. rewrite: (path) => path.replace(/^\/adapter/, ""),
  42. },
  43. "^/custom": {
  44. target: "http://123.60.219.66:8060",
  45. // target: 'http://wanghs.nat300.top',
  46. changeOrigin: true, //开启代理
  47. rewrite: (path) => path.replace(/^\/custom/, ""),
  48. },
  49. "^/windturbine": {
  50. target: "http://123.60.219.66:8071",
  51. // target: 'http://wanghs.nat300.top',
  52. changeOrigin: true, //开启代理
  53. rewrite: (path) => path.replace(/^\/windturbine/, ""),
  54. },
  55. "^/scadas": {
  56. target: "http://123.60.219.66:8072",
  57. // target: 'http://wanghs.nat300.top',
  58. changeOrigin: true, //开启代理
  59. rewrite: (path) => path.replace(/^\/scadas/, ""),
  60. },
  61. },
  62. },
  63. });