Files
bili-shadowreplay/vite.config.ts

66 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-04-28 21:25:35 +08:00
import { defineConfig, loadEnv } from "vite";
2024-10-19 13:50:14 +08:00
import { resolve } from "path";
2023-04-08 15:33:41 +08:00
import { svelte } from "@sveltejs/vite-plugin-svelte";
import sveltePreprocess from "svelte-preprocess";
2025-04-28 21:25:35 +08:00
import { readFileSync } from "fs";
2023-04-08 15:33:41 +08:00
2025-04-28 21:25:35 +08:00
// Read package.json
const packageJson = JSON.parse(
readFileSync(resolve(__dirname, "package.json"), "utf-8")
);
2023-04-08 15:33:41 +08:00
// https://vitejs.dev/config/
// @ts-ignore
2025-04-28 21:25:35 +08:00
export default defineConfig(async ({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), "");
2023-04-08 15:33:41 +08:00
2025-04-28 21:25:35 +08:00
return {
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),
__API_BASE_URL__: JSON.stringify(env.API_BASE_URL || ""),
},
optimizeDeps: {
exclude: ["@ffmpeg/ffmpeg", "@ffmpeg/util"],
},
plugins: [
svelte({
preprocess: [
sveltePreprocess({
typescript: true,
}),
],
}),
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 8054,
strictPort: true,
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: {
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
live: resolve(__dirname, "index_live.html"),
clip: resolve(__dirname, "index_clip.html"),
2025-04-28 21:25:35 +08:00
},
2024-10-19 13:50:14 +08:00
},
2025-04-28 21:25:35 +08:00
// 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,
2024-10-19 13:50:14 +08:00
},
2025-04-28 21:25:35 +08:00
};
});