43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
const host = process.env.TAURI_DEV_HOST;
|
|
// Support custom port via environment variable (default 1420 for Tauri, 19420 for Docker)
|
|
const port = parseInt(process.env.VITE_DEV_SERVER_PORT || '1420', 10);
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
|
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
|
// prevent vite from obscuring rust errors
|
|
clearScreen: false,
|
|
|
|
server: {
|
|
port,
|
|
strictPort: true,
|
|
host: host || false,
|
|
hmr: host
|
|
? {
|
|
protocol: 'ws',
|
|
host,
|
|
port: port + 1,
|
|
}
|
|
: undefined,
|
|
watch: {
|
|
// Watch the src-tauri folder for Rust changes
|
|
ignored: ['**/src-tauri/**'],
|
|
},
|
|
},
|
|
|
|
envPrefix: ['VITE_', 'TAURI_'],
|
|
|
|
build: {
|
|
// Tauri uses Chromium on Windows and WebKit on macOS and Linux
|
|
target: process.env.TAURI_ENV_PLATFORM === 'windows' ? 'chrome105' : 'safari13',
|
|
// don't minify for debug builds
|
|
minify: !process.env.TAURI_ENV_DEBUG ? 'esbuild' : false,
|
|
// produce sourcemaps for debug builds
|
|
sourcemap: !!process.env.TAURI_ENV_DEBUG,
|
|
},
|
|
});
|