// file: crates/ksp-app-config-desk/vite.config.ts // version: 2 import { NodePackageImporter } from "sass-embedded"; import { fileURLToPath } from "node:url"; import { resolve } from "node:path"; import { defineConfig, normalizePath } from "vite"; const appRoot = fileURLToPath(new URL(".", import.meta.url)); const frontendRoot = normalizePath(resolve(appRoot, "frontend")); const frontendDist = normalizePath(resolve(appRoot, "../../../builds/khadhroony-solana-project/ksp-app-config-desk/dist")); const devHost = process.env.TAURI_DEV_HOST; export default defineConfig({ clearScreen: false, root: frontendRoot, publicDir: false, input: { main: normalizePath(resolve(frontendRoot, "main.html")), splash: normalizePath(resolve(frontendRoot, "splash.html")), }, build: { outDir: frontendDist, emptyOutDir: true, minify: true, sourcemap: false, cssCodeSplit: true, rolldownOptions: { output: { entryFileNames: "js/[name]-[hash].js", chunkFileNames: "js/chunks/[name]-[hash].js", assetFileNames: assetInfo => { const originalName = assetInfo.names[0] ?? ""; const extension = originalName.substring(originalName.lastIndexOf(".") + 1).toLowerCase(); if (extension === "css") { return "css/[name]-[hash][extname]"; } if (["eot", "otf", "ttf", "woff", "woff2"].includes(extension)) { return "fonts/[name]-[hash][extname]"; } if (["png", "jpg", "jpeg", "gif", "svg", "webp", "ico"].includes(extension)) { return "imgs/[name][extname]"; } return "otherassets/[name][extname]"; }, }, }, }, css: { preprocessorOptions: { scss: { quietDeps: true, silenceDeprecations: ["import", "color-functions", "global-builtin"], verbose: false, importers: [new NodePackageImporter()], }, }, }, server: { port: 1430, strictPort: true, host: devHost || false, ws: { protocol: "ws", host: devHost || "localhost", port: 1431, }, watch: { ignored: ["**/src/**"], }, }, });