55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
// 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 web‐dev 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,
|
||
},
|
||
}),
|
||
}
|
||
})
|