From 9eab699e2a386c19b981e5dfd694e168a1a33a35 Mon Sep 17 00:00:00 2001 From: Koala <6156589+Shik3i@users.noreply.github.com> Date: Mon, 1 Jun 2026 02:14:31 +0200 Subject: [PATCH] feat(website): output minified files as .min.* for safety and clarity --- AI_INIT.md | 2 +- website/README.md | 4 ++-- website/build.js | 19 +++++++++++++++---- website/datenschutz.html | 8 ++++---- website/impressum.html | 8 ++++---- website/join.html | 8 ++++---- website/template.html | 8 ++++---- website/www/{app.js => app.min.js} | 0 website/www/datenschutz.html | 8 ++++---- website/www/de/index.html | 8 ++++---- website/www/es/index.html | 8 ++++---- website/www/fr/index.html | 8 ++++---- website/www/impressum.html | 8 ++++---- website/www/index.html | 8 ++++---- website/www/join.html | 8 ++++---- .../www/{lang-init.js => lang-init.min.js} | 0 website/www/pt-BR/index.html | 8 ++++---- website/www/ru/index.html | 8 ++++---- website/www/{style.css => style.min.css} | 0 19 files changed, 70 insertions(+), 59 deletions(-) rename website/www/{app.js => app.min.js} (100%) rename website/www/{lang-init.js => lang-init.min.js} (100%) rename website/www/{style.css => style.min.css} (100%) diff --git a/AI_INIT.md b/AI_INIT.md index 79bcc88..b5bd422 100644 --- a/AI_INIT.md +++ b/AI_INIT.md @@ -22,7 +22,7 @@ KoalaSync is a specialized tool for **synchronized video playback** across multi - `server/`: Node.js Relay Server using Socket.IO (WebSocket-only). - `website/`: **Landing Page** & Invitation Bridge (Marketing, Tutorials, and Downloads). - **`build.js`**: Zero-dependency static site compiler. Translates `template.html` + `locales/*.json` → `www/`. Also minifies CSS/JS automatically. - - **`www/` is auto-generated**: Never edit files in `www/` directly. Always edit source files (`template.html`, `style.css`, `app.js`, `lang-init.js`, `locales/*.json`) and run `node website/build.js` to regenerate. + - **`www/` is auto-generated**: Never edit files in `www/` directly. Always edit source files (`template.html`, `style.css`, `app.js`, `lang-init.js`, `locales/*.json`) and run `node website/build.js` to regenerate. CSS/JS are output as `.min.*` files — a built-in cleanup step removes stale artifacts on each build. - `shared/`: **Single Source of Truth** for protocol constants and event names. - `scripts/`: Development utilities (e.g., `build-extension.js`). - `docker-compose.yml`: Root-level orchestration for the relay server. diff --git a/website/README.md b/website/README.md index ff84d35..cf6c62a 100644 --- a/website/README.md +++ b/website/README.md @@ -17,7 +17,7 @@ The website handles incoming invitation links. When a user clicks a link like `s The website is 100% **Static HTML, CSS, and JS**. - **Static i18n Compiler**: The site uses a lightweight, zero-dependency Node.js compiler (`build.js`) to parse dictionary files inside `/locales/` against a single source-of-truth template (`template.html`), outputting the fully deployable static folder to `/www/`. -- **Build-time Minification**: `build.js` automatically minifies CSS and JS during compilation using a built-in state-machine tokenizer (no npm dependencies). Source files are written unminified — always edit source files, never the generated files in `www/`. +- **Build-time Minification**: `build.js` automatically minifies CSS and JS during compilation using a built-in state-machine tokenizer (no npm dependencies). Source files are written unminified (`style.css`, `app.js`, `lang-init.js`) — always edit source files, never the generated `.min.*` files in `www/`. - **Zero Backend**: No Node.js, PHP, or databases are required to host the compiled website. - **Zero Tracking**: All assets (fonts, icons) are self-hosted to prevent third-party tracking. - **Responsive**: Fully optimized for mobile with a native-feel hamburger menu. @@ -71,4 +71,4 @@ sync.koalastuff.net { 3. To test the invitation flow locally, navigate to `http://localhost:5000/join.html#join:test-room:test-pass`. > [!IMPORTANT] -> **Never edit files inside `website/www/` directly.** This directory is fully auto-generated by `build.js`. Always edit source files (`template.html`, `style.css`, `app.js`, `lang-init.js`, locale files in `locales/`) and re-run `node website/build.js` to apply changes. CSS and JS are minified during the build — editing minified files in `www/` will result in lost changes on the next build. +> **Never edit files inside `website/www/` directly.** This directory is fully auto-generated by `build.js`. Always edit source files (`template.html`, `style.css`, `app.js`, `lang-init.js`, locale files in `locales/`) and re-run `node website/build.js` to apply changes. CSS and JS are output as `style.min.css`, `app.min.js`, and `lang-init.min.js` — the `.min.*` naming makes it visually obvious these are build artifacts. Editing minified files in `www/` will result in lost changes on the next build. diff --git a/website/build.js b/website/build.js index 1f0e2ff..bde1221 100644 --- a/website/build.js +++ b/website/build.js @@ -164,7 +164,14 @@ function compile() { } } - // 5. Copy static assets + // 5. Clean stale minified output from previous builds + const staleGlobs = ['style.css', 'style.min.css', 'app.js', 'app.min.js', 'lang-init.js', 'lang-init.min.js']; + for (let f of staleGlobs) { + const p = path.join(wwwDir, f); + if (fs.existsSync(p)) fs.unlinkSync(p); + } + + // 6. Copy static assets console.log('Copying assets and static website files...'); const staticFiles = [ 'style.css', @@ -180,20 +187,24 @@ function compile() { for (let file of staticFiles) { const srcPath = path.join(websiteDir, file); - const destPath = path.join(wwwDir, file); + // Rename .css → .min.css and .js → .min.js in output + const destName = file.endsWith('.css') ? file.replace(/\.css$/, '.min.css') + : file.endsWith('.js') ? file.replace(/\.js$/, '.min.js') + : file; + const destPath = path.join(wwwDir, destName); if (fs.existsSync(srcPath)) { if (file.endsWith('.css')) { const raw = fs.readFileSync(srcPath, 'utf8'); const minified = minifyCSS(raw); fs.writeFileSync(destPath, minified, 'utf8'); const saved = ((raw.length - minified.length) / raw.length * 100).toFixed(0); - console.log(`Minified: ${file} (-${saved}%)`); + console.log(`Minified: ${file} → ${destName} (-${saved}%)`); } else if (file.endsWith('.js')) { const raw = fs.readFileSync(srcPath, 'utf8'); const minified = minifyJS(raw); fs.writeFileSync(destPath, minified, 'utf8'); const saved = ((raw.length - minified.length) / raw.length * 100).toFixed(0); - console.log(`Minified: ${file} (-${saved}%)`); + console.log(`Minified: ${file} → ${destName} (-${saved}%)`); } else { fs.copyFileSync(srcPath, destPath); console.log(`Copied: ${file}`); diff --git a/website/datenschutz.html b/website/datenschutz.html index ec1d53d..fcd0c72 100644 --- a/website/datenschutz.html +++ b/website/datenschutz.html @@ -4,8 +4,8 @@ Datenschutz / Privacy Policy | KoalaSync - - + + @@ -14,7 +14,7 @@ - +
@@ -205,6 +205,6 @@
- + diff --git a/website/impressum.html b/website/impressum.html index 72536c5..dde294b 100644 --- a/website/impressum.html +++ b/website/impressum.html @@ -4,8 +4,8 @@ Impressum / Legal Notice | KoalaSync - - + + @@ -14,7 +14,7 @@ - +
@@ -179,6 +179,6 @@
- + diff --git a/website/join.html b/website/join.html index f9d2c93..c6d0efb 100644 --- a/website/join.html +++ b/website/join.html @@ -4,8 +4,8 @@ Join Room | KoalaSync - - + + @@ -27,7 +27,7 @@ - +
@@ -117,6 +117,6 @@
- + diff --git a/website/template.html b/website/template.html index 05534bb..db1eb72 100644 --- a/website/template.html +++ b/website/template.html @@ -6,9 +6,9 @@ {{META_TITLE}} - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/app.js b/website/www/app.min.js similarity index 100% rename from website/www/app.js rename to website/www/app.min.js diff --git a/website/www/datenschutz.html b/website/www/datenschutz.html index ec1d53d..fcd0c72 100644 --- a/website/www/datenschutz.html +++ b/website/www/datenschutz.html @@ -4,8 +4,8 @@ Datenschutz / Privacy Policy | KoalaSync - - + + @@ -14,7 +14,7 @@ - +
@@ -205,6 +205,6 @@
- + diff --git a/website/www/de/index.html b/website/www/de/index.html index 7417f9f..08f7166 100644 --- a/website/www/de/index.html +++ b/website/www/de/index.html @@ -6,9 +6,9 @@ KoalaSync | Netflix, YouTube & jedes Video mit Freunden synchronisieren - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/es/index.html b/website/www/es/index.html index 4e43f1a..42e026f 100644 --- a/website/www/es/index.html +++ b/website/www/es/index.html @@ -6,9 +6,9 @@ KoalaSync | Sincroniza Netflix, YouTube y cualquier video con amigos - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/fr/index.html b/website/www/fr/index.html index 2e31e31..650d687 100644 --- a/website/www/fr/index.html +++ b/website/www/fr/index.html @@ -6,9 +6,9 @@ KoalaSync | Synchronisez Netflix, YouTube et n'importe quelle vidéo avec vos amis - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/impressum.html b/website/www/impressum.html index 72536c5..dde294b 100644 --- a/website/www/impressum.html +++ b/website/www/impressum.html @@ -4,8 +4,8 @@ Impressum / Legal Notice | KoalaSync - - + + @@ -14,7 +14,7 @@ - +
@@ -179,6 +179,6 @@
- + diff --git a/website/www/index.html b/website/www/index.html index 1a06656..8c838a6 100644 --- a/website/www/index.html +++ b/website/www/index.html @@ -6,9 +6,9 @@ KoalaSync | Sync Netflix, YouTube & Any Video with Friends - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/join.html b/website/www/join.html index f9d2c93..c6d0efb 100644 --- a/website/www/join.html +++ b/website/www/join.html @@ -4,8 +4,8 @@ Join Room | KoalaSync - - + + @@ -27,7 +27,7 @@ - +
@@ -117,6 +117,6 @@
- + diff --git a/website/www/lang-init.js b/website/www/lang-init.min.js similarity index 100% rename from website/www/lang-init.js rename to website/www/lang-init.min.js diff --git a/website/www/pt-BR/index.html b/website/www/pt-BR/index.html index 6b80226..0d66f22 100644 --- a/website/www/pt-BR/index.html +++ b/website/www/pt-BR/index.html @@ -6,9 +6,9 @@ KoalaSync | Sincronize Netflix, YouTube e qualquer vídeo com amigos - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/ru/index.html b/website/www/ru/index.html index c8b635e..a6f3af1 100644 --- a/website/www/ru/index.html +++ b/website/www/ru/index.html @@ -6,9 +6,9 @@ KoalaSync | Синхронизация Netflix, YouTube и любого видео с друзьями - + - + @@ -40,7 +40,7 @@ - + + diff --git a/website/www/style.css b/website/www/style.min.css similarity index 100% rename from website/www/style.css rename to website/www/style.min.css