vat_wms/vite.config.ts
2025-07-09 15:35:23 +02:00

55 lines
1.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// vite.config.ts
import { defineConfig } from 'vite'
import laravel from 'laravel-vite-plugin'
import react from '@vitejs/plugin-react'
export default defineConfig(({ command }) => {
const isDev = command === 'serve'
const isBuild = command === 'build'
// set EMULATOR=1 in your npm script when you want to work on the Android build
const isEmulator = !!process.env.EMULATOR
return {
// for webdev we load from “/”, for the Capacitor build we need “./”
base: isBuild ? './' : '/',
plugins: [
laravel({
input: 'resources/js/app.tsx',
refresh: true,
}),
react(),
],
resolve: {
alias: {
'@': '/resources/js',
},
},
// only spin up a dev server when running `vite` or `npm run dev`
...(isDev && {
server: {
// if you do `--host`, Vite will override this to 0.0.0.0
host: isEmulator ? '0.0.0.0' : 'localhost',
port: 5173,
strictPort: true,
cors: true,
hmr: {
// emulator needs 10.0.2.2, browser just localhost
host: isEmulator ? '10.0.2.2' : 'localhost',
port: 5173,
},
},
}),
// only emit your Capacitor build when running `vite build` or `npm run build`
...(isBuild && {
build: {
outDir: 'public/spa',
emptyOutDir: true,
},
}),
}
})