-
Notifications
You must be signed in to change notification settings - Fork 24
/
vite.config.mjs
93 lines (88 loc) · 2.63 KB
/
vite.config.mjs
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
import { codecovVitePlugin } from '@codecov/vite-plugin'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import react from '@vitejs/plugin-react'
import { defineConfig, loadEnv } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import { ViteEjsPlugin } from 'vite-plugin-ejs'
import svgr from 'vite-plugin-svgr'
import legacy from '@vitejs/plugin-legacy'
import { ViteReactSourcemapsPlugin } from '@acemarke/react-prod-sourcemaps'
export default defineConfig((config) => {
const env = loadEnv(config.mode, process.cwd(), 'REACT_APP')
const envWithProcessPrefix = {
'process.env': `${JSON.stringify(env)}`,
}
const plugins = []
if (
process.env.CODECOV_API_URL &&
process.env.CODECOV_ORG_TOKEN &&
process.env.UPLOAD_CODECOV_BUNDLE_STATS === 'true'
) {
plugins.push(
codecovVitePlugin({
enableBundleAnalysis:
process.env.UPLOAD_CODECOV_BUNDLE_STATS === 'true',
bundleName: process.env.CODECOV_BUNDLE_NAME,
apiUrl: process.env.CODECOV_API_URL,
uploadToken: process.env.CODECOV_ORG_TOKEN,
debug: true
})
)
}
const runSentryPlugin =
config.mode === 'production' && !!process.env.SENTRY_AUTH_TOKEN
if (runSentryPlugin) {
plugins.push(
ViteReactSourcemapsPlugin({
debug: false,
preserve: false,
}),
sentryVitePlugin({
applicationKey: 'gazebo',
org: process.env.SENTRY_ORG || 'codecov',
project: process.env.REACT_APP_SENTRY_PROJECT || 'gazebo',
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
name: process.env.GAZEBO_SHA,
deploy: {
env:
process.env.REACT_APP_SENTRY_ENVIRONMENT || process.env.NODE_ENV,
},
},
})
)
}
return {
server: {
port: 3000,
},
build: {
outDir: 'build',
sourcemap: runSentryPlugin,
rollupOptions: {
output: {
entryFileNames: 'assets/[name].[hash:22].js',
chunkFileNames: 'assets/[name].[hash:22].js',
assetFileNames: 'assets/[name].[hash:22][extname]',
},
},
},
define: envWithProcessPrefix,
plugins: [
ViteEjsPlugin({
isProduction: process.env.REACT_APP_ENV === 'production',
REACT_APP_PENDO_KEY: process.env.REACT_APP_PENDO_KEY,
}),
tsconfigPaths(),
legacy({
// which legacy browsers to support
targets: ['>0.2%', 'not dead', 'not op_mini all'],
// which polyfills to include in the modern build
modernPolyfills: ['es.promise.all-settled'],
}),
react(),
svgr(),
...plugins,
],
}
})