Files
new-api/web/vite.config.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-03-23 19:09:09 +08:00
import react from '@vitejs/plugin-react';
2024-03-23 21:23:39 +08:00
import { defineConfig, transformWithEsbuild } from 'vite';
2024-03-23 19:09:09 +08:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
{
name: 'treat-js-files-as-jsx',
async transform(code, id) {
2024-03-23 21:23:39 +08:00
if (!/src\/.*\.js$/.test(id)) {
return null;
}
2024-03-23 19:09:09 +08:00
// Use the exposed transform from vite, instead of directly
// transforming with esbuild
return transformWithEsbuild(code, id, {
loader: 'jsx',
jsx: 'automatic',
2024-03-23 21:23:39 +08:00
});
2024-03-23 19:09:09 +08:00
},
},
react(),
],
optimizeDeps: {
force: true,
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
2024-03-23 19:37:19 +08:00
build: {
rollupOptions: {
output: {
manualChunks: {
2024-03-23 20:22:00 +08:00
'react-core': ['react', 'react-dom', 'react-router-dom'],
'semi-ui': ['@douyinfe/semi-icons', '@douyinfe/semi-ui'],
2024-03-23 21:23:39 +08:00
semantic: ['semantic-ui-offline', 'semantic-ui-react'],
visactor: ['@visactor/react-vchart', '@visactor/vchart'],
tools: ['axios', 'history', 'marked'],
'react-components': [
'react-dropzone',
'react-fireworks',
'react-telegram-login',
'react-toastify',
'react-turnstile',
],
2024-03-23 19:37:19 +08:00
},
},
},
},
2024-03-23 19:09:09 +08:00
server: {
proxy: {
'/api': {
2024-03-23 21:23:39 +08:00
target: 'http://localhost:3000',
2024-03-23 19:09:09 +08:00
changeOrigin: true,
2024-03-23 21:23:39 +08:00
},
},
},
2024-03-23 19:09:09 +08:00
});