import { defineConfig } from "vite"; // import { darkTheme } from "./src/theme.js"; import vue from "@vitejs/plugin-vue"; import Components from "unplugin-vue-components/vite"; import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"; import { visualizer } from "rollup-plugin-visualizer"; import svgLoader from "vite-svg-loader"; import path from "path"; import basicSsl from "@vitejs/plugin-basic-ssl"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), Components({ resolvers: [AntDesignVueResolver()], }), visualizer({ open: false, gzipSize: true, file: "./dist/stats.html", brotliSize: true, }), svgLoader(), basicSsl(), ], server: { proxy: { //配置本地代理 "/api/": { //匹配的路径 target: "http://aixq.shqp.gov.cn", //目标url changeOrigin: true, //跨域 rewrite: (path) => path.replace(/^\/api/, ""), //重写路径 }, // 新版聊天后端代理(POST /api/chat,SSE) // 开发服务器是 HTTPS 而后端是 HTTP,浏览器会拦截直连(混合内容), // 且后端未实现 CORS,因此开发环境统一走同源代理。 // 对应 .env.development 中 VITE_CHAT_API="/chat-api" "/chat-api/": { target: "http://192.168.2.23:8000", changeOrigin: true, rewrite: (path) => path.replace(/^\/chat-api/, ""), }, "/asr/": { //匹配的路径 target: "https://human-screen-v3.metamaker.cn", //目标url changeOrigin: true, //跨域 rewrite: (path) => path.replace(/^\/asr/, ""), //重写路径 ws: true, }, "/stream/": { //匹配的路径 target: "https://flv-enc.metamaker.cn", //目标url changeOrigin: true, //跨域 rewrite: (path) => path.replace(/^\/stream/, ""), //重写路径 ws: true, headers: { Connection: "keep-alive", }, }, }, }, build: { rollupOptions: { input: { main: path.resolve(__dirname, "index.html"), redirect: path.resolve(__dirname, "redirect.html"), }, output: { manualChunks: (id) => { console.log(id); if (id.includes("node_modules/three")) { return "three"; } else if (id.includes("node_modules")) { return "vendor"; } }, }, }, assetsInlineLimit: 20480, }, resolve: { alias: { "@": path.resolve("./src/"), three$: path.resolve(__dirname, "./node_modules/three/build/three.cjs"), }, }, base: "./", css: { preprocessorOptions: { scss: { api: "modern-compiler", }, }, }, });