Skip to content

Add guide: Tauri + Vite #431

@JonasKruckenberg

Description

@JonasKruckenberg

Setup

  • link to vite setup
  • link to tauri setup
  • add tauri to vite project
  • recommended config
    {
      // prevent vite from obscuring rust errors
      clearScreen: false,
      // tauri expects a fixed port, fail if that port is not available
      server: {
        port: 3000,
        strictPort: true,
      },
      // to make use of `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`, `TAURI_PLATFORM_VERSION`, `TAURI_PLATFORM_TYPE` and `TAURI_DEBUG` env variables
      envPrefix: ['VITE_', 'TAURI_'],
      build: {
        // tauri supports es2021
        target: ['es2021', 'chrome97', 'safari13'],
        // don't minify for debug builds
        minify: !process.env.TAURI_DEBUG && 'esbuild',
        // produce sourcemaps for debug builds
        sourcemap: !!process.env.TAURI_DEBUG,
      },
    }

Development

  • mention HMR
  • link to React, Vue, Svelte guides

Building

  • explain vite build (short)
  • explain how tauri build will find the assets

SSR

  • mention import.meta.env.SSR
  • link to vite SSR guide

Plugin recommendations

  • vite has a wide variety of plugins, but many features are already built in
  • many rollup plugins can be used too
  • recommend some good plugins to use when developing native apps
    • tauri-plugin-vite is a quick and easy way to add tauri to you vite app
    • vite-imagetools (shameless plug) or rollup-plugin-imagemin to optimize images

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions