vite-plugin-tauri

raw JSON →
4.0.0 verified Mon Apr 27 auth: no javascript

Integrates Tauri into a Vite project, enabling cross-platform desktop app development with seamless dev and build workflows. Current stable version is 4.0.0, which adds support for Tauri v2 and removes the debug, verbose, and target config options in favor of CLI arguments. The plugin is actively maintained and distributed as an ESM-only package. It ships TypeScript types and requires @tauri-apps/cli >=1 and vite >=2 as peer dependencies. Key differentiators include automatic detection of Tauri project initialization, support for separate Vite configs for Tauri, and CLI argument passthrough via -- -t or --tauri syntax. Version 3.1.0 introduced a default export alongside the named export, and version 3.0.2 removed internal modification of vite clearScreen and server.open settings.

error Error: Cannot find module 'vite-plugin-tauri'
cause Package not installed or in node_modules
fix
Run 'npm install -D vite-plugin-tauri @tauri-apps/cli'
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/vite-plugin-tauri not supported.
cause Using CommonJS require() on an ESM-only package
fix
Switch to import statement: import tauri from 'vite-plugin-tauri' or set type:module in package.json
error TypeError: tauri is not a function
cause Using default import incorrectly or wrong import path
fix
Ensure you import correctly: import tauri from 'vite-plugin-tauri' (default) or import { tauri } from 'vite-plugin-tauri' (named)
error error: unknown option `--verbose'
cause Passing Tauri CLI arguments directly to vite without -- separator
fix
Use -- -t or -- --tauri before Tauri arguments: npm run dev -- -- -t --verbose
breaking Removed debug, verbose, and target config options in v4.0.0
fix Pass these options as Tauri CLI arguments, e.g., pnpm dev -- -t --verbose --release
deprecated Named export { tauri } is still supported, but default export is preferred since v3.1.0
fix Use import tauri from 'vite-plugin-tauri' instead of import { tauri } from 'vite-plugin-tauri'
gotcha CommonJS require() will fail because package is ESM-only
fix Use ES module import syntax in your project (set type:module in package.json or use .mjs files)
breaking Internal modification of clearScreen and server.open was removed in v3.0.2
fix Manually set clearScreen: false and server.open: false in your Vite config if desired
npm install vite-plugin-tauri
yarn add vite-plugin-tauri
pnpm add vite-plugin-tauri

Shows how to install, import, and configure the plugin in a Vite config with optional but recommended settings.

// vite.config.js
import { defineConfig } from 'vite';
import tauri from 'vite-plugin-tauri';

export default defineConfig({
  plugins: [tauri()],
  clearScreen: false,
  server: {
    open: false,
  },
});

// Then in terminal:
// pnpm add -D vite-plugin-tauri @tauri-apps/cli
// npx tauri init
// pnpm dev -- -t --release