64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import { xiBadgePlugin } from 'vite-plugin-xi-plus-badge';
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
tsconfigPaths(),
|
|
xiBadgePlugin({
|
|
text: 'XI PLUS', // 角标文本
|
|
link: 'https://xi.plus', // 点击跳转链接
|
|
position: 'bottom-right', // 角标位置
|
|
showInDev: true, // 开发环境显示
|
|
showInProd: true // 生产环境显示
|
|
})
|
|
],
|
|
build: {
|
|
sourcemap: 'hidden',
|
|
// 代码分割优化
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vendor: ['react', 'react-dom', 'react-router-dom'],
|
|
ui: ['lucide-react'],
|
|
utils: ['zustand', 'socket.io-client']
|
|
}
|
|
}
|
|
},
|
|
// 压缩优化
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true
|
|
}
|
|
},
|
|
// 构建性能优化
|
|
chunkSizeWarningLimit: 1000
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:3010',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
configure: (proxy) => {
|
|
proxy.on('error', (err) => {
|
|
console.log('proxy error', err);
|
|
});
|
|
proxy.on('proxyReq', (proxyReq, req) => {
|
|
console.log('Sending Request to the Target:', req.method, req.url);
|
|
});
|
|
proxy.on('proxyRes', (proxyRes, req) => {
|
|
console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
|
|
});
|
|
}
|
|
}
|
|
},
|
|
allowedHosts: ['draw.xi.plus', 'draw.ngx.center']
|
|
},
|
|
})
|