-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
69 lines (68 loc) · 1.81 KB
/
vite.config.ts
File metadata and controls
69 lines (68 loc) · 1.81 KB
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
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import fs from 'fs'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
// Ensure root-level config.json is available in the production bundle
{
name: 'copy-config-json',
apply: 'build',
closeBundle() {
try {
const src = path.resolve(__dirname, 'config.json')
const outDir = 'dist'
const destDir = path.resolve(__dirname, outDir)
const dest = path.resolve(destDir, 'config.json')
if (fs.existsSync(src)) {
fs.mkdirSync(destDir, { recursive: true })
fs.copyFileSync(src, dest)
console.log('[copy-config-json] copied config.json ->', dest)
} else {
console.warn('[copy-config-json] config.json not found at project root')
}
} catch (e) {
console.warn('[copy-config-json] failed to copy config.json:', e)
}
},
},
],
// Prevent blank screen in production builds
base: './',
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
clearScreen: false,
server: {
port: 5173,
strictPort: true,
watch: {
ignored: ['**/src-tauri/**'],
},
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: false,
secure: false,
}
}
},
// Vitest configuration
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
css: true,
},
envPrefix: ['VITE_', 'TAURI_'],
build: {
target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13',
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
sourcemap: !!process.env.TAURI_DEBUG,
},
})