Refactor: JS in js/, LESS in less/, clientseitige Less-Kompilierung via less.js CDN

This commit is contained in:
2026-05-25 01:54:53 +02:00
parent f5d6d59cdd
commit 3b1a4ce4e4
6 changed files with 5 additions and 45 deletions

View File

@@ -1,30 +0,0 @@
/* global require, __dirname, process */
const less = require('less');
const fs = require('fs');
const path = require('path');
const src = path.join(__dirname, 'style.less');
const dest = path.join(__dirname, 'style.css');
fs.readFile(src, 'utf8', (err, data) => {
if (err) {
console.error('[LESS] Fehler beim Lesen:', err.message);
process.exit(1);
}
less.render(data, {
filename: src,
compress: false,
sourceMap: false,
}).then(output => {
fs.writeFile(dest, output.css, 'utf8', err => {
if (err) {
console.error('[LESS] Fehler beim Schreiben:', err.message);
process.exit(1);
}
console.log('[LESS] style.less → style.css erfolgreich kompiliert');
});
}).catch(err => {
console.error('[LESS] Kompilierungsfehler:', err.message);
process.exit(1);
});
});

View File

@@ -5,7 +5,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🏆 Lara Kiesewetter Live Schachturnier</title> <title>🏆 Lara Kiesewetter Live Schachturnier</title>
<link rel="stylesheet" href="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.css"> <link rel="stylesheet" href="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.css">
<link rel="stylesheet" href="style.css"> <link rel="stylesheet/less" href="less/style.less">
<script>less = { env: 'development' };</script>
<script src="https://cdn.jsdelivr.net/npm/less@4.6.4/dist/less.min.js"></script>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
@@ -93,7 +95,7 @@
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.js"></script> <script src="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.3/chess.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.3/chess.min.js"></script>
<script src="pgn-parser.js"></script> <script src="js/pgn-parser.js"></script>
<script src="app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>

View File

View File

@@ -7,7 +7,6 @@ Serviert statische Dateien direkt.
import http.server import http.server
import socketserver import socketserver
import os import os
import subprocess
PORT = int(os.environ.get("PORT", 8111)) PORT = int(os.environ.get("PORT", 8111))
@@ -48,17 +47,6 @@ class StaticHandler(http.server.BaseHTTPRequestHandler):
print(f"[{self.log_date_time_string()}] {args[0]}") print(f"[{self.log_date_time_string()}] {args[0]}")
def main(): def main():
# LESS → CSS beim Serverstart kompilieren
print("[BUILD] Kompiliere style.less -> style.css ...")
try:
result = subprocess.run(["node", "build-less.js"], capture_output=True, text=True, cwd=os.path.dirname(os.path.abspath(__file__)))
if result.returncode == 0:
print(f"[BUILD] {result.stdout.strip()}")
else:
print(f"[BUILD] FEHLER: {result.stderr.strip()}")
except FileNotFoundError:
print("[BUILD] node nicht gefunden überspringe LESS-Kompilierung")
print("=" * 50) print("=" * 50)
print(" [TROPHY] Lara Kiesewetter Live Schachturnier") print(" [TROPHY] Lara Kiesewetter Live Schachturnier")
print("=" * 50) print("=" * 50)