-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathvite.config.ts
More file actions
80 lines (77 loc) · 2.26 KB
/
vite.config.ts
File metadata and controls
80 lines (77 loc) · 2.26 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
69
70
71
72
73
74
75
76
77
78
79
80
import { defineConfig } from 'vite'
import { version } from './package.json'
import react from '@vitejs/plugin-react'
import { visualizer } from 'rollup-plugin-visualizer'
import compression from 'vite-plugin-compression'
import svgr from 'vite-plugin-svgr'
export const commonConfig = {
define: {
__VERSION__: JSON.stringify(version),
__PR_NUMBER__: JSON.stringify(process.env.PR_NUMBER),
__PRODUCTION__: JSON.stringify(process.env.NODE_ENV !== 'development'),
__DICTIONARY_UPDATE_TIME: JSON.stringify(new Date().toUTCString()),
},
resolve: {
alias: {
'translations': '/src/translations',
'components': '/src/components',
'reducers': '/src/reducers',
'services': '/src/services',
'routing': '/src/routing',
'actions': '/src/actions',
'consts': '/src/consts',
'utils': '/src/utils',
'hooks': '/src/hooks',
},
},
}
export default defineConfig({
publicDir: 'static',
plugins: [
react(),
svgr({
svgrOptions: { exportType: 'default' },
include: '**/*.svg',
}),
visualizer({
filename: 'report.html',
gzipSize: true,
}),
compression({
algorithm: 'brotliCompress',
ext: '.br',
threshold: 1,
compressionOptions: { level: 11 },
verbose: true,
}),
compression({
algorithm: 'gzip',
ext: '.gz',
threshold: 1,
verbose: true,
}),
],
optimizeDeps: {
include: ['react', 'react-dom'],
},
build: {
outDir: 'dist',
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('react')) return 'react'
if (id.includes('react-dom')) return 'react-dom'
}
},
entryFileNames: 'assets/[name].js',
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]',
},
},
},
server: {
port: 3000,
},
...commonConfig,
})