2025-09-20 00:09:00 +08:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
import svgr from "vite-plugin-svgr";
|
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
svgr({
|
|
|
|
|
svgrOptions: {
|
|
|
|
|
icon: true,
|
|
|
|
|
exportType: "named",
|
|
|
|
|
namedExport: "ReactComponent",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-10-22 15:12:59 +08:00
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
|
|
|
|
vendor: ['react', 'react-dom', 'react-router-dom'],
|
|
|
|
|
ui: [
|
|
|
|
|
'@radix-ui/react-dialog',
|
|
|
|
|
'@radix-ui/react-select',
|
|
|
|
|
'@radix-ui/react-tabs',
|
|
|
|
|
'@radix-ui/react-progress'
|
|
|
|
|
],
|
|
|
|
|
charts: ['recharts'],
|
|
|
|
|
ai: ['@google/generative-ai'],
|
|
|
|
|
utils: ['clsx', 'tailwind-merge', 'date-fns', 'sonner']
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
chunkSizeWarningLimit: 1000,
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
minify: 'terser',
|
|
|
|
|
terserOptions: {
|
|
|
|
|
compress: {
|
|
|
|
|
drop_console: true,
|
|
|
|
|
drop_debugger: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
host: true,
|
|
|
|
|
open: true,
|
2025-10-30 14:58:20 +08:00
|
|
|
cors: {
|
|
|
|
|
origin: true,
|
|
|
|
|
credentials: true,
|
|
|
|
|
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
|
|
|
|
|
allowedHeaders: [
|
|
|
|
|
"Authorization",
|
|
|
|
|
"Content-Type",
|
|
|
|
|
"X-DashScope-SSE",
|
|
|
|
|
"X-Requested-With",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
proxy: {
|
2025-11-26 21:11:12 +08:00
|
|
|
"/api": {
|
|
|
|
|
target: process.env.VITE_API_TARGET || "http://127.0.0.1:8000",
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: false,
|
|
|
|
|
},
|
2025-10-30 14:58:20 +08:00
|
|
|
"/dashscope-proxy": {
|
|
|
|
|
target: "https://dashscope.aliyuncs.com",
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/dashscope-proxy/, ""),
|
|
|
|
|
configure: (proxy) => {
|
|
|
|
|
proxy.on("proxyReq", (proxyReq) => {
|
|
|
|
|
proxyReq.setHeader("origin", "https://dashscope.aliyuncs.com");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-10-22 15:12:59 +08:00
|
|
|
},
|
|
|
|
|
preview: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
host: true,
|
|
|
|
|
},
|
|
|
|
|
optimizeDeps: {
|
|
|
|
|
include: [
|
|
|
|
|
'react',
|
|
|
|
|
'react-dom',
|
|
|
|
|
'react-router-dom',
|
|
|
|
|
'@google/generative-ai',
|
|
|
|
|
'recharts',
|
|
|
|
|
'sonner'
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
});
|