-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
48 lines (45 loc) · 1.33 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
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import envCompatible from 'vite-plugin-env-compatible'
import { createHtmlPlugin } from 'vite-plugin-html'
const ENV_PREFIX = 'REACT_APP_'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, 'env', ENV_PREFIX)
return {
plugins: [
react(),
envCompatible({ prefix: ENV_PREFIX }),
createHtmlPlugin({
inject: {
data: {
env: {
NODE_ENV: process.env.NODE_ENV,
REACT_APP_CLIENT_TOKEN: process.env.REACT_APP_CLIENT_TOKEN,
REACT_APP_ENV: process.env.REACT_APP_ENV
}
}
},
minify: true
})
],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/setupTests.js']
},
resolve: {
alias: {
'~': path.resolve(__dirname, 'src')
}
},
server: {
port: 3000,
open: env.SERVER_OPEN_BROWSER === 'true'
},
build: {
outDir: 'build'
}
}
})