-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
122 lines (121 loc) · 3.85 KB
/
vite.config.ts
File metadata and controls
122 lines (121 loc) · 3.85 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import react from '@vitejs/plugin-react-swc';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import { VitePluginRadar } from 'vite-plugin-radar';
import svgr from 'vite-plugin-svgr';
import wasm from 'vite-plugin-wasm';
export default defineConfig({
esbuild: {
drop: ['console', 'debugger'], // production 빌드 시 console과 debugger 제거
},
plugins: [
react(),
svgr(),
wasm(),
VitePluginRadar({
analytics: {
id: 'G-EZPQMV95QJ',
},
}),
visualizer({
filename: './dist/stats.html',
open: false,
gzipSize: true,
}),
VitePWA({
devOptions: { enabled: false },
registerType: 'autoUpdate',
workbox: {
cleanupOutdatedCaches: true, // 이전 캐시 삭제
globPatterns: ['**/*.{js,css,html,ico,png,svg}'], // 필요한 파일만 포함
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5MB로 상향 조정
runtimeCaching: [
{
urlPattern: ({ request }) =>
request.destination === 'script' || request.destination === 'style' || request.destination === 'document',
handler: 'NetworkOnly', // 네트워크만 사용
},
],
},
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'mask-icon.svg'],
manifest: {
name: 'humanzipyo',
short_name: 'humanzipyo',
theme_color: '#5270FF',
background_color: '#000000',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
}),
],
build: {
rollupOptions: {
output: {
manualChunks: {
// React 관련 라이브러리를 별도 청크로 분리
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
// React Query를 별도 청크로 분리
'query-vendor': ['react-query'],
// UI 라이브러리를 별도 청크로 분리
'ui-vendor': ['@emotion/react', '@emotion/styled', 'framer-motion'],
},
// 파일명 해시 추가로 브라우저 캐싱 최적화
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
},
},
// 500KB 목표로 청크 사이즈 제한
chunkSizeWarningLimit: 500,
// 소스맵 비활성화로 빌드 크기 감소
sourcemap: false,
// 최소화 옵션
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log', 'console.info', 'console.debug'],
},
},
},
resolve: {
alias: [
{ find: '@ts', replacement: '/src/ts' },
{ find: '@utils', replacement: '/src/utils' },
{ find: '@hooks', replacement: '/src/hooks' },
{ find: '@pages', replacement: '/src/pages' },
{ find: '@router', replacement: '/src/router' },
{ find: '@layout', replacement: '/src/layout' },
{ find: '@constants', replacement: '/src/constants' },
{ find: '@controllers', replacement: '/src/controllers' },
{ find: '@components', replacement: '/src/components' },
{ find: '@styles', replacement: '/src/styles' },
{ find: '@assets', replacement: '/src/assets' },
{ find: '@config', replacement: '/src/config' },
],
},
});