-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
74 lines (72 loc) · 1.76 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
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import EnvironmentPlugin from 'vite-plugin-environment'
import VitePluginHtmlEnv from 'vite-plugin-html-env'
import react from '@vitejs/plugin-react-swc'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import path from 'path'
import svgr from 'vite-plugin-svgr'
export const generateConfig: Parameters<typeof defineConfig>[0] = ({ mode }) => ({
resolve: {
alias: {
'~': path.resolve(__dirname, 'src/'),
},
},
plugins: [
react(),
svgr(),
VitePluginHtmlEnv({
envPrefixes: ['REACT_APP_'],
}),
EnvironmentPlugin('all', { prefix: 'REACT_APP_' }),
splitVendorChunkPlugin(),
sentryVitePlugin({
disable: mode !== 'production',
org: process.env.SENTRY_ORG,
telemetry: false,
sourcemaps: {
assets: 'build/assets/**',
filesToDeleteAfterUpload: 'build/assets/*.js.map',
},
release: {
deploy: {
env: process.env.APP_ENV || 'production',
},
},
}),
],
server: {
open: true,
port: 3000,
},
build: {
outDir: 'build',
sourcemap: mode === 'production' ? 'hidden' : true,
rollupOptions: {
onLog(level, log, handler) {
if (log.cause instanceof Error && log.cause.message === "Can't resolve original location of error.") {
return
}
handler(level, log)
},
},
},
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' },
},
test: {
globals: true,
environment: 'jsdom',
coverage: {
reporter: ['text', 'json', 'html'],
},
dir: 'src',
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
})
export default defineConfig(generateConfig)