Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
vite-plugin-build-info.ts44 linesDownload Raw Back to scripts
1import { BUILD_CONFIG } from '../src/lib/constants/pwa.constants';2import { existsSync, writeFileSync } from 'node:fs';3import { resolve } from 'path';4import type { Plugin } from 'vite';5 6let processed = false;7 8const OUTPUT_DIR = process.env.LLAMA_UI_OUT_DIR ?? BUILD_CONFIG.OUTPUT_DIR;9 10/**11 * Write build.json with the llama.cpp release build number.12 *13 * LLAMA_BUILD_NUMBER is passed from CMake -> npm -> vite via env var.14 * Used for display of the current llama-server release (e.g. "b1234").15 */16export function buildInfoPlugin(): Plugin {17	return {18		apply: 'build',19		closeBundle() {20			setTimeout(() => {21				try {22					if (processed) return;23 24					processed = true;25 26					const buildNumber = process.env.LLAMA_BUILD_NUMBER || 'b0000';27					const outDir = resolve(OUTPUT_DIR);28					const indexPath = resolve(outDir, 'index.html');29 30					if (!existsSync(indexPath)) return;31 32					const buildJsonPath = resolve(outDir, 'build.json');33 34					writeFileSync(buildJsonPath, JSON.stringify({ version: buildNumber }), 'utf-8');35					console.log(`Created build.json (version: ${buildNumber})`);36				} catch (error) {37					console.error('Failed to write build.json:', error);38				}39			}, 100);40		},41		name: 'llamacpp:build-info'42	};43}44