jan/web-app/vite.config.ts
Louis 81c4dc516b
chore: handle hardware settings (#5041)
* chore: handle hardware settings

* chore: activate GPUs

* Update web-app/src/services/hardware.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-20 20:05:47 +07:00

69 lines
1.9 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import packageJson from './package.json'
const host = process.env.TAURI_DEV_HOST
// https://vite.dev/config/
export default defineConfig({
plugins: [
TanStackRouterVite({ target: 'react', autoCodeSplitting: true }),
react(),
tailwindcss(),
nodePolyfills({
include: ['path'],
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
define: {
IS_TAURI: JSON.stringify(process.env.IS_TAURI),
IS_MACOS: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('darwin') ?? 'false'
),
IS_WINDOWS: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('windows') ?? 'false'
),
IS_LINUX: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('unix') ?? 'false'
),
IS_IOS: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('ios') ?? 'false'
),
IS_ANDROID: JSON.stringify(
process.env.TAURI_ENV_PLATFORM?.includes('android') ?? 'false'
),
PLATFORM: JSON.stringify(process.env.TAURI_ENV_PLATFORM),
VERSION: JSON.stringify(packageJson.version),
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
},
})