-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
56 lines (54 loc) · 1.42 KB
/
vite.config.js
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
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
const env = loadEnv(mode, '.')
return {
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.js',
},
base: env.VITE_BASE_PATH || '/',
server: {
port: 5173,
strictPort: true,
open: true,
},
preview: {
port: 4173,
strictPort: true,
open: true,
},
build: {
outDir: 'dist',
assetsDir: 'assets',
sourcemap: mode !== 'production',
// Generate manifest file for PWA
manifest: true,
// Customize rollup build options
rollupOptions: {
output: {
// Ensure chunk filenames include content hash
assetFileNames: 'assets/[name]-[hash][extname]',
chunkFileNames: 'assets/[name]-[hash].js',
entryFileNames: 'assets/[name]-[hash].js',
// Implement manual chunks for better code splitting
manualChunks: {
vendor: [
'react',
'react-dom',
'react-router-dom'
],
},
},
},
},
define: {
// Pass environment variables to the client
__APP_ENV__: JSON.stringify(env.VITE_APP_ENV),
},
}
})