-
Notifications
You must be signed in to change notification settings - Fork 646
Expand file tree
/
Copy pathvite.config.mjs
More file actions
68 lines (66 loc) · 2.05 KB
/
vite.config.mjs
File metadata and controls
68 lines (66 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import jsconfigPaths from 'vite-jsconfig-paths';
import path from 'path';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const API_URL = env.VITE_APP_BASE_NAME || '/';
const PORT = 3000;
return {
base: API_URL,
server: {
open: true,
port: PORT,
host: true
},
preview: {
open: true,
host: true,
fs: {
allow: ['..']
}
},
define: {
global: 'window'
},
resolve: {
alias: {
'@ant-design/icons': path.resolve(__dirname, 'node_modules/@ant-design/icons')
// Add more aliases as needed
}
},
plugins: [react(), jsconfigPaths()],
build: {
chunkSizeWarningLimit: 1000,
sourcemap: true,
cssCodeSplit: true,
rollupOptions: {
output: {
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
assetFileNames: (assetInfo) => {
const name = assetInfo.name || '';
const ext = name.split('.').pop();
if (/\.css$/.test(name)) return `css/[name]-[hash].${ext}`;
if (/\.(png|jpe?g|gif|svg|webp|ico)$/.test(name)) return `images/[name]-[hash].${ext}`;
if (/\.(woff2?|eot|ttf|otf)$/.test(name)) return `fonts/[name]-[hash].${ext}`;
return `assets/[name]-[hash].${ext}`;
}
// manualChunks: { ... } // Add if you want custom chunk splitting
}
},
// Only drop console/debugger in production
...(mode === 'production' && {
esbuild: {
drop: ['console', 'debugger'],
pure: ['console.log', 'console.info', 'console.debug', 'console.warn']
}
})
// No need to set build.target unless you need to support older browsers
// target: 'baseline-widely-available', // This is now the default
},
optimizeDeps: {
include: ['@mui/material/Tooltip', 'react', 'react-dom', 'react-router-dom']
}
};
});