Files
2026-05-14 19:55:53 +08:00

55 lines
1.3 KiB
TypeScript

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
plugins: [react()],
define: {
'process.env': {},
},
resolve: {
// new URL is pure ESM — no __dirname needed, no @types/node required
alias: { '@': new URL('./src', import.meta.url).pathname },
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
// no rewrite: /api/... proxied as-is to http://localhost:8080/api/...
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
lexical: [
'lexical',
'@lexical/react',
'@lexical/rich-text',
'@lexical/list',
'@lexical/code',
'@lexical/table',
],
semi: ['@douyinfe/semi-ui', '@douyinfe/semi-icons'],
excalidraw: ['@excalidraw/excalidraw'],
vendor: ['react', 'react-dom', 'react-router', 'axios'],
yjs: ['yjs', 'y-websocket'],
},
},
},
},
esbuild: {
// strip console.* and debugger in production builds
drop: command === 'build' ? (['console', 'debugger'] as const) : [],
},
}));