Upgrade to Tauri 2.0 (#23)

This commit is contained in:
Gregory Schier
2024-05-04 14:14:19 -07:00
committed by GitHub
parent 7f02060b9c
commit 896e3d5831
128 changed files with 20477 additions and 4114 deletions

View File

@@ -1,34 +1,29 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { internalIpV4 } from 'internal-ip';
import svgr from 'vite-plugin-svgr';
import topLevelAwait from 'vite-plugin-top-level-await';
// https://vitejs.dev/config/
const config = defineConfig({
plugins: [svgr(), react({}), topLevelAwait()],
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM);
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [svgr(), react(), topLevelAwait()],
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: mobile ? '0.0.0.0' : false,
hmr: mobile
? {
protocol: 'ws',
host: await internalIpV4(),
port: 1421,
}
: undefined,
watch: {
ignored: ['**/src-tauri/**', '**/designs/**', '**/plugins/**'],
},
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ['VITE_', 'TAURI_'],
build: {
// Tauri supports es2021
target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13',
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
// Who cares
chunkSizeWarningLimit: Infinity,
},
});
export default config;
}));