-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
55 lines (47 loc) · 1.33 KB
/
vite.config.ts
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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
import { dependencies } from './package.json'
import * as path from 'path'
// https://vitejs.dev/config/
//const vendorChunks = ['react', 'react-router-dom', 'react-dom', 'react-helmet-async'];
const ignoredChunks = []
function renderChunks(deps: Record<string, string>) {
const chunks = {}
Object.keys(deps).forEach((key) => {
if (ignoredChunks.includes(key)) return
//if (vendorChunks.includes(key)) return;
chunks[key] = [key]
})
return chunks
}
export default defineConfig({
plugins: [react(), tsconfigPaths()],
base: './', // this is needed for the app to work in subdirectories
resolve: {
alias: {
'~react-toastify': path.resolve(__dirname, 'node_modules/react-toastify'),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler', // or "modern"
},
},
},
build: {
sourcemap: false, // only for debugging
minify: 'esbuild', // or "terser" (esbuild is faster)
cssCodeSplit: true, // separate css for better caching
rollupOptions: {
output: {
manualChunks: {
//vendor: vendorChunks,
...renderChunks(dependencies),
},
},
},
},
})