vite.config.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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:6015",
  34. // target: "http://192.168.1.110:6015",
  35. changeOrigin: true, //开启代理
  36. rewrite: (path) => path.replace(/^\/sharding/, ""),
  37. },
  38. "^/adapter": {
  39. target: "http://123.60.219.66:8011",
  40. // target: 'http://wanghs.nat300.top',
  41. changeOrigin: true, //开启代理
  42. rewrite: (path) => path.replace(/^\/adapter/, ""),
  43. },
  44. "^/custom": {
  45. target: "http://123.60.219.66:8060",
  46. // target: 'http://wanghs.nat300.top',
  47. changeOrigin: true, //开启代理
  48. rewrite: (path) => path.replace(/^\/custom/, ""),
  49. },
  50. "^/windturbine": {
  51. target: "http://123.60.219.66:8071",
  52. // target: 'http://wanghs.nat300.top',
  53. changeOrigin: true, //开启代理
  54. rewrite: (path) => path.replace(/^\/windturbine/, ""),
  55. },
  56. "^/scadas": {
  57. target: "http://123.60.219.66:8072",
  58. // target: 'http://wanghs.nat300.top',
  59. changeOrigin: true, //开启代理
  60. rewrite: (path) => path.replace(/^\/scadas/, ""),
  61. },
  62. },
  63. },
  64. });