-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
103 lines (101 loc) · 2.42 KB
/
vite.config.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import viteCompression from 'vite-plugin-compression'
export default defineConfig({
base: '/github_dashboard/',
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin']
}
}),
viteCompression({
verbose: true,
disable: false,
threshold: 1024,
algorithm: 'gzip',
ext: '.gz',
filter: (file) => {
return file.endsWith('.json') ||
file.endsWith('.js') ||
file.endsWith('.css')
}
})
],
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html')
},
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('react') || id.includes('@emotion') || id.includes('@mui')) {
return 'vendor-core'
}
if (id.includes('recharts')) {
return 'vendor-charts'
}
if (id.includes('lodash')) {
return 'vendor-utils'
}
return 'vendor-misc'
}
if (id.includes('/src/components/dashboard/')) {
return 'app-dashboard'
}
if (id.includes('/src/components/')) {
return 'app-components'
}
if (id.includes('/src/data/')) {
return 'app-data'
}
}
}
},
target: 'esnext',
minify: 'esbuild',
cssCodeSplit: true,
chunkSizeWarningLimit: 400,
sourcemap: true,
assetsInlineLimit: 4096,
emptyOutDir: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
optimizeDeps: {
include: [
'react',
'react-dom',
'@mui/material',
'@mui/icons-material',
'recharts',
'lodash',
'@emotion/react',
'@emotion/styled',
'@emotion/cache',
'@emotion/utils',
'@emotion/weak-memoize',
'@emotion/memoize',
'@emotion/sheet',
'@emotion/serialize',
'hoist-non-react-statics'
],
esbuildOptions: {
mainFields: ['module', 'main'],
resolveExtensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
loader: {
'.js': 'jsx'
}
}
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' }
}
})