feat: Initialize Svelte frontend with Vite, Tailwind CSS, single-file build, and a gzip script for ESP32 deployment.

This commit is contained in:
2026-03-02 20:47:52 -05:00
parent 6d457e4744
commit 1d30773234
4 changed files with 134 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
/**
* Gzip script for ESP32 deployment.
* Compresses dist/index.html -> dist/index.html.gz
* Uses Node.js built-in zlib (no extra dependencies).
*/
import { readFileSync, writeFileSync } from 'fs';
import { gzipSync } from 'zlib';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const inputPath = resolve(__dirname, '..', 'dist', 'index.html');
const outputPath = resolve(__dirname, '..', 'dist', 'index.html.gz');
const input = readFileSync(inputPath);
const compressed = gzipSync(input, { level: 9 });
writeFileSync(outputPath, compressed);
const inputKB = (input.length / 1024).toFixed(1);
const outputKB = (compressed.length / 1024).toFixed(1);
const ratio = ((1 - compressed.length / input.length) * 100).toFixed(0);
console.log(`Gzip: ${inputKB} kB -> ${outputKB} kB (${ratio}% reduction)`);
console.log(`Output: dist/index.html.gz`);