v64: рефакторинг — разбил монолит на css/ js/ build.sh dist/ (781→43 строки index.html)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Склеивает CSS/JS в единый index.html для деплоя (ConfigMap — один файл)."""
|
||||
import os
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
html = open(os.path.join(BASE, 'index.html')).read()
|
||||
|
||||
css = open(os.path.join(BASE, 'css/style.css')).read()
|
||||
html = html.replace('<link rel="stylesheet" href="css/style.css">',
|
||||
f'<style>\n{css}\n</style>')
|
||||
|
||||
for jsf in ['storage.js', 'syllables.js', 'transcribe.js', 'audio.js', 'compare.js', 'main.js']:
|
||||
js = open(os.path.join(BASE, 'js', jsf)).read()
|
||||
html = html.replace(f'<script src="js/{jsf}"></script>',
|
||||
f'<script>\n{js}\n</script>')
|
||||
|
||||
os.makedirs(os.path.join(BASE, 'dist'), exist_ok=True)
|
||||
with open(os.path.join(BASE, 'dist/index.html'), 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
print(f'dist/index.html ready ({len(html)} bytes)')
|
||||
Reference in New Issue
Block a user