-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
61 lines (54 loc) · 1.63 KB
/
Copy pathvite.config.js
File metadata and controls
61 lines (54 loc) · 1.63 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
const PDF_EXPORT_VENDOR_CHUNKS = ['jspdf-vendor', 'html2canvas-vendor']
const VITE_PRELOAD_HELPER_ID = 'vite/preload-helper'
function isPdfExportVendorDependency(dependency) {
return PDF_EXPORT_VENDOR_CHUNKS.some((chunkName) =>
dependency.includes(`${chunkName}-`) || dependency.includes(`${chunkName}.`),
)
}
// https://vite.dev/config/
export default defineConfig(({ command }) => {
const isBuild = command === 'build'
return {
plugins: [react()],
build: {
// 배포 번들에서 소스맵 파일 생성을 막아 원본 추적 노출을 줄임
sourcemap: false,
minify: 'esbuild',
cssMinify: true,
modulePreload: {
resolveDependencies(_url, deps, { hostType }) {
if (hostType !== 'html') {
return deps
}
return deps.filter((dependency) => !isPdfExportVendorDependency(dependency))
},
},
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes(VITE_PRELOAD_HELPER_ID)) {
return 'vite-preload-helper'
}
if (id.includes('node_modules/jspdf')) {
return 'jspdf-vendor'
}
if (id.includes('node_modules/html2canvas')) {
return 'html2canvas-vendor'
}
},
},
},
},
esbuild: isBuild
? {
minifyIdentifiers: true,
minifySyntax: true,
minifyWhitespace: true,
legalComments: 'none',
drop: ['console', 'debugger'],
}
: undefined,
}
})