-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvite.config.ts
100 lines (95 loc) · 2.59 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
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
/* eslint-disable no-undef */
import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import imagemin from 'vite-plugin-imagemin';
import checker from 'vite-plugin-checker';
import { visualizer } from 'rollup-plugin-visualizer';
import viteCompression from 'vite-plugin-compression';
import pkg from './package.json' assert { type: 'json' };
import tailwindcss from '@tailwindcss/vite';
interface ReactCompilerConfig {
target?: string;
sources?: (filename: string) => boolean;
logLevel?: 'debug' | 'info' | 'warn' | 'error';
}
const baseCompilerConfig: ReactCompilerConfig = {
target: '19',
};
const devCompilerConfig: ReactCompilerConfig = {
...baseCompilerConfig,
logLevel: 'debug',
};
export default defineConfig(({ mode }) => ({
build: {
target: 'esnext',
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
manualChunks: {
radix: Object.keys(pkg.dependencies).filter((dep) => dep.startsWith('@radix-ui')),
tanstack: ['@tanstack/react-query', '@tanstack/react-table'],
animation: ['framer-motion', 'embla-carousel-react'],
},
},
treeshake: true,
preserveEntrySignatures: 'exports-only',
},
assetsInlineLimit: 4096,
},
plugins: [
tailwindcss(),
mode === 'production' &&
imagemin({
gifsicle: { optimizationLevel: 3 },
mozjpeg: { quality: 80 },
optipng: { optimizationLevel: 5 },
svgo: {
plugins: [{ name: 'removeViewBox' }, { name: 'removeEmptyAttrs', active: false }],
},
}),
react({
jsxRuntime: 'automatic',
jsxImportSource: 'react',
babel: {
plugins: [
[
'babel-plugin-react-compiler',
{
target: '19',
logLevel: process.env.NODE_ENV === 'development' ? 'debug' : undefined,
},
],
],
},
}),
// checker({
// typescript: true,
// eslint: {
// lintCommand: 'eslint .', // Simplified command
// dev: {
// logLevel: ['error'],
// },
// },
// overlay: false,
// }),
viteCompression({ algorithm: 'gzip' }),
visualizer({
open: true,
filename: 'dist/stats.html',
}),
].filter(Boolean),
optimizeDeps: {
include: ['react', 'react-dom', 'framer-motion', 'lucide-react'],
exclude: ['@tanstack/react-query'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
envPrefix: 'APP',
define: {
'process.env.NODE_ENV': JSON.stringify(mode),
},
}));