vite.config.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { defineConfig } from "vite";
  2. // import { darkTheme } from "./src/theme.js";
  3. import vue from "@vitejs/plugin-vue";
  4. import Components from "unplugin-vue-components/vite";
  5. import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
  6. import { visualizer } from "rollup-plugin-visualizer";
  7. import svgLoader from "vite-svg-loader";
  8. import path from "path";
  9. import basicSsl from "@vitejs/plugin-basic-ssl";
  10. // https://vitejs.dev/config/
  11. export default defineConfig({
  12. plugins: [
  13. vue(),
  14. Components({
  15. resolvers: [AntDesignVueResolver()],
  16. }),
  17. visualizer({
  18. open: false,
  19. gzipSize: true,
  20. file: "./dist/stats.html",
  21. brotliSize: true,
  22. }),
  23. svgLoader(),
  24. basicSsl(),
  25. ],
  26. server: {
  27. proxy: {
  28. //配置本地代理
  29. "/api/": {
  30. //匹配的路径
  31. target: "http://aixq.shqp.gov.cn", //目标url
  32. changeOrigin: true, //跨域
  33. rewrite: (path) => path.replace(/^\/api/, ""), //重写路径
  34. },
  35. // 新版聊天后端代理(POST /api/chat,SSE)
  36. // 开发服务器是 HTTPS 而后端是 HTTP,浏览器会拦截直连(混合内容),
  37. // 且后端未实现 CORS,因此开发环境统一走同源代理。
  38. // 对应 .env.development 中 VITE_CHAT_API="/chat-api"
  39. "/chat-api/": {
  40. target: "http://192.168.2.23:8000",
  41. changeOrigin: true,
  42. rewrite: (path) => path.replace(/^\/chat-api/, ""),
  43. },
  44. "/asr/": {
  45. //匹配的路径
  46. target: "https://human-screen-v3.metamaker.cn", //目标url
  47. changeOrigin: true, //跨域
  48. rewrite: (path) => path.replace(/^\/asr/, ""), //重写路径
  49. ws: true,
  50. },
  51. "/stream/": {
  52. //匹配的路径
  53. target: "https://flv-enc.metamaker.cn", //目标url
  54. changeOrigin: true, //跨域
  55. rewrite: (path) => path.replace(/^\/stream/, ""), //重写路径
  56. ws: true,
  57. headers: {
  58. Connection: "keep-alive",
  59. },
  60. },
  61. },
  62. },
  63. build: {
  64. rollupOptions: {
  65. input: {
  66. main: path.resolve(__dirname, "index.html"),
  67. redirect: path.resolve(__dirname, "redirect.html"),
  68. },
  69. output: {
  70. manualChunks: (id) => {
  71. console.log(id);
  72. if (id.includes("node_modules/three")) {
  73. return "three";
  74. } else if (id.includes("node_modules")) {
  75. return "vendor";
  76. }
  77. },
  78. },
  79. },
  80. assetsInlineLimit: 20480,
  81. },
  82. resolve: {
  83. alias: {
  84. "@": path.resolve("./src/"),
  85. three$: path.resolve(__dirname, "./node_modules/three/build/three.cjs"),
  86. },
  87. },
  88. base: "./",
  89. css: {
  90. preprocessorOptions: {
  91. scss: {
  92. api: "modern-compiler",
  93. },
  94. },
  95. },
  96. });