-
Notifications
You must be signed in to change notification settings - Fork 68
/
vite.config.ts
37 lines (34 loc) · 1.18 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
import { defineConfig, splitVendorChunkPlugin, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import json5 from '@miyaneee/rollup-plugin-json5'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode, ssrBuild }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')
const isProd = env.NODE_ENV === "production"
return {
plugins: [
// Ensure vite can handle react/jsx code
react(),
// Create a relevant vendor chunk for bundling optimization
splitVendorChunkPlugin(),
// Load JSON5 as modules
json5()
],
// Add sourcemaps to the production build
...(isProd && {build: {sourcemap: true}}),
// Test configuration for vitest
test: {
environment: 'jsdom',
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/test/e2e/**'
],
},
}
})