This commit is contained in:
2026-04-20 15:32:19 +02:00
commit 0858b72e31
36 changed files with 6359 additions and 0 deletions

80
kb_app/vite.config.ts Normal file
View File

@@ -0,0 +1,80 @@
// file: kb_app/vite.config.ts
import { defineConfig, normalizePath } from "vite";
import { NodePackageImporter } from "sass-embedded";
import { resolve } from 'path';
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
envPrefix: ['VITE_', 'TAURI_ENV_*'],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
root: 'frontend', // Set this to your frontend directory
publicDir: 'public',
build: {
outDir: './dist', // Output directory for the build
emptyOutDir: true,
rollupOptions: {
input: {
"main": normalizePath(resolve(__dirname, 'frontend/index.html'))
},
output: {
entryFileNames: 'js/[name]-[hash].js',
chunkFileNames: 'js/chunks/[name]-[hash].js',
assetFileNames: (assetInfo) => {
const originalName = assetInfo.name ?? '';
const ext = originalName.substring(originalName.lastIndexOf('.') + 1).toLowerCase();
if (ext === 'js') {
return 'js/[name]-[hash][extname]';
}
// CSS
if (ext === 'css') {
return 'css/[name]-[hash][extname]';
}
if (['eot', 'otf', 'ttf', 'woff', 'woff2'].includes(ext)) {
return 'fonts/[name]-[hash][extname]';
}
if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico'].includes(ext)) {
return 'imgs/[name][extname]';
}
if (['mp4', 'webm'].includes(ext)) {
return 'videos/[name][extname]';
}
return 'otherassets/[name][extname]';
},
},
},
minify: true,
sourcemap: false,
cssCodeSplit: true
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
importers: [new NodePackageImporter()],
}
}
},
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: false,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
ignored: ["**/src/**"],
},
},
}));