@proj-airi/cap-vite
CLI for Capacitor live-reload development using Vite.
Usage
pnpm cap-vite ios <DEVICE_ID_OR_SIMULATOR_NAME>
pnpm cap-vite android <DEVICE_ID_OR_SIMULATOR_NAME>
# Or
CAPACITOR_DEVICE_ID=<DEVICE_ID_OR_SIMULATOR_NAME> pnpm cap-vite ios
CAPACITOR_DEVICE_ID=<DEVICE_ID_OR_SIMULATOR_NAME> pnpm cap-vite android
You can see the list of available devices and simulators by running pnpm exec cap run ios --list or pnpm exec cap run android --list.
Capacitor Configuration
You need to set server.url in capacitor.config.ts to the env variable CAPACITOR_DEV_SERVER_URL.
const serverURL = env.CAPACITOR_DEV_SERVER_URL
const config: CapacitorConfig = {
appId: 'com.example.app',
appName: 'Example App',
webDir: 'dist',
server: serverURL
? {
url: serverURL,
cleartext: false,
}
: undefined,
}
export default config
What It Does
- Starts the project's own Vite config through the Vite API.
- Executes the local
capbinary viatinyexec. - Watches native files under
ios/orandroid/and re-runscap runafter a small debounce.