-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
93 lines (91 loc) · 2.5 KB
/
vite.config.js
File metadata and controls
93 lines (91 loc) · 2.5 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
81
82
83
84
85
86
87
88
89
90
91
92
93
/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import legacy from '@vitejs/plugin-legacy';
import path from 'path';
import { fileURLToPath } from 'url';
import { visualizer } from 'rollup-plugin-visualizer';
import viteCompression from 'vite-plugin-compression';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default defineConfig({
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin'],
},
}),
ViteImageOptimizer({
webp: {
lossless: false,
quality: 75,
},
avif: false,
}),
visualizer({
open: true,
filename: './dist/report.html',
}),
viteTsconfigPaths(),
svgrPlugin(),
legacy({
targets: ['edge >= 87', 'chrome >= 90'],
modernPolyfills: true,
}),
viteCompression({
algorithm: 'brotliCompress',
ext: '.br',
}),
viteCompression({
algorithm: 'gzip',
ext: '.gz',
}),
],
resolve: {
alias: {
'@assets': path.resolve(__dirname, 'src/assets'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@features': path.resolve(__dirname, 'src/features'),
'@components': path.resolve(__dirname, 'src/components'),
'@layout': path.resolve(__dirname, 'src/layout'),
'@apis': path.resolve(__dirname, 'src/apis'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@common': path.resolve(__dirname, 'src/common'),
'@mocks': path.resolve(__dirname, 'src/mocks'),
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.js'],
css: true,
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('gsap') || id.includes('framer-motion')) {
return 'animation';
}
if (id.includes('sweetalert2')) {
return 'sweetalert2';
}
if (id.includes('lottie-react')) {
return 'lottie-react';
}
if (id.includes('emotion')) {
return 'emotion';
}
if (id.includes('node_modules')) {
return 'vendor';
}
},
},
},
},
});