91 lines
2.2 KiB
JavaScript
91 lines
2.2 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const manualChunks = (id) => {
|
|
if (!id.includes('node_modules')) {
|
|
return undefined;
|
|
}
|
|
|
|
const normalizedId = id.split('node_modules/')[1];
|
|
|
|
if (
|
|
normalizedId.startsWith('react/') ||
|
|
normalizedId.startsWith('react-dom/') ||
|
|
normalizedId.startsWith('scheduler/')
|
|
) {
|
|
return 'react-vendor';
|
|
}
|
|
|
|
if (
|
|
normalizedId.startsWith('@ant-design/icons/') ||
|
|
normalizedId.startsWith('@ant-design/icons-svg/')
|
|
) {
|
|
return 'ant-icons-vendor';
|
|
}
|
|
|
|
if (normalizedId.startsWith('axios/')) {
|
|
return 'http-vendor';
|
|
}
|
|
|
|
if (normalizedId.startsWith('yaml/')) {
|
|
return 'yaml-vendor';
|
|
}
|
|
|
|
if (
|
|
normalizedId.startsWith('markdown-it/') ||
|
|
normalizedId.startsWith('markdown-it-') ||
|
|
normalizedId.startsWith('linkify-it/') ||
|
|
normalizedId.startsWith('mdurl/') ||
|
|
normalizedId.startsWith('uc.micro/') ||
|
|
normalizedId.startsWith('entities/') ||
|
|
normalizedId.startsWith('punycode.js/') ||
|
|
normalizedId.startsWith('katex/') ||
|
|
normalizedId.startsWith('@vscode/markdown-it-katex/')
|
|
) {
|
|
return 'markdown-parser-vendor';
|
|
}
|
|
|
|
if (
|
|
normalizedId.startsWith('html2canvas/') ||
|
|
normalizedId.startsWith('jspdf/') ||
|
|
normalizedId.startsWith('canvg/')
|
|
) {
|
|
return 'capture-vendor';
|
|
}
|
|
|
|
if (
|
|
normalizedId.startsWith('qrcode.react/') ||
|
|
normalizedId.startsWith('qrcode/')
|
|
) {
|
|
return 'qrcode-vendor';
|
|
}
|
|
|
|
return undefined;
|
|
};
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
host: true, // Optional: Allows the server to be accessible externally
|
|
allowedHosts: ['dev.imeeting.unisspace.com','nonperforated-ivonne-fezzy.ngrok-free.dev'], // Add the problematic hostname here
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8000', // 后端服务地址
|
|
changeOrigin: true, // 是否改变请求的源头
|
|
},
|
|
'/uploads': {
|
|
target: 'http://localhost:8000', // 后端服务地址
|
|
changeOrigin: true, // 是否改变请求的源头
|
|
},
|
|
},
|
|
}
|
|
})
|