From a6ff866376f0d4d12b2fbcbf04c0fc07b45f4534 Mon Sep 17 00:00:00 2001 From: StarKnightt Date: Wed, 16 Apr 2025 21:24:48 +0530 Subject: [PATCH] fixed stuffs --- package-lock.json | 18 ++++++++++++++++++ package.json | 1 + landing.html => public/index.html | 0 vite.config.ts | 16 ++++++++++------ 4 files changed, 29 insertions(+), 6 deletions(-) rename landing.html => public/index.html (100%) diff --git a/package-lock.json b/package-lock.json index e1c7d61..decda87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@tauri-apps/cli": "^1.6.3", + "@types/node": "^22.14.1", "@types/react": "^18.2.48", "@types/react-dom": "^18.2.18", "@vitejs/plugin-react": "^4.2.1", @@ -1321,6 +1322,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/node": { + "version": "22.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.1.tgz", + "integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, "node_modules/@types/prop-types": { "version": "15.7.14", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.14.tgz", @@ -1815,6 +1826,13 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, "node_modules/update-browserslist-db": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", diff --git a/package.json b/package.json index 1282752..325640c 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@tauri-apps/cli": "^1.6.3", + "@types/node": "^22.14.1", "@types/react": "^18.2.48", "@types/react-dom": "^18.2.18", "@vitejs/plugin-react": "^4.2.1", diff --git a/landing.html b/public/index.html similarity index 100% rename from landing.html rename to public/index.html diff --git a/vite.config.ts b/vite.config.ts index 0ebbeb6..d56064a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,12 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; +import type { UserConfig } from 'vite'; -// @ts-expect-error process is a nodejs global -const host = process.env.TAURI_DEV_HOST; +const host = process.env.TAURI_DEV_HOST ?? false; +const isTauri = Boolean(process.env.TAURI_DEBUG || process.env.TAURI_PLATFORM); // https://vitejs.dev/config/ -export default defineConfig(async () => ({ +export default defineConfig({ plugins: [react()], // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` @@ -16,7 +17,7 @@ export default defineConfig(async () => ({ server: { port: 1420, strictPort: true, - host: host || false, + host, hmr: host ? { protocol: "ws", @@ -33,12 +34,15 @@ export default defineConfig(async () => ({ // Production optimizations build: { // Tauri uses Chromium on Windows and WebKit on macOS and Linux - target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13', + 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, rollupOptions: { + input: { + main: isTauri ? './index.html' : './public/index.html' + }, output: { manualChunks: { react: ['react', 'react-dom'], @@ -47,4 +51,4 @@ export default defineConfig(async () => ({ } } } -})); +} satisfies UserConfig); \ No newline at end of file