-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvite.config.js
More file actions
73 lines (71 loc) · 2.09 KB
/
Copy pathvite.config.js
File metadata and controls
73 lines (71 loc) · 2.09 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
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { viteFastify } from '@fastify/vite/plugin'
import viteReact from '@vitejs/plugin-react'
import { compression } from 'vite-plugin-compression2'
const packageJson = JSON.parse(
readFileSync(new URL('./package.json', import.meta.url), 'utf8'),
)
/** @type {import('vite').UserConfig} */
export default {
base: './',
root: resolve(import.meta.dirname, 'src/client'),
plugins: [
viteReact(),
viteFastify({ spa: true }),
compression({ algorithms: ['gzip', 'brotliCompress'], threshold: 1024 }),
],
build: {
outDir: resolve(import.meta.dirname, 'dist'),
emptyOutDir: false,
assetsInclude: ['**/*.woff2', '**/*.woff'],
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{
name: 'react-vendor',
test: /[\\/]node_modules[\\/](react|react-dom|react-router-dom)[\\/]/,
priority: 20,
},
{
name: 'ui-vendor',
test: /[\\/]node_modules[\\/]lucide-react[\\/]/,
priority: 15,
},
{
name: 'query',
test: /[\\/]node_modules[\\/]@tanstack[\\/]react-query[\\/]/,
priority: 15,
},
{
name: 'table',
test: /[\\/]node_modules[\\/]@tanstack[\\/]react-table[\\/]/,
priority: 15,
},
{
name: 'charts',
test: /[\\/]node_modules[\\/]recharts[\\/]/,
priority: 15,
},
{
name: 'forms',
test: /[\\/]node_modules[\\/](react-hook-form|@hookform[\\/]resolvers|zod)[\\/]/,
priority: 15,
},
],
},
},
},
},
resolve: {
alias: {
'@': resolve(import.meta.dirname, 'src/client'),
'@root': resolve(import.meta.dirname, 'src'),
},
},
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),
},
cacheDir: process.env.NODE_ENV === 'production' ? false : undefined,
}