22 lines
877 B
Bash
Executable File
22 lines
877 B
Bash
Executable File
#!/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)')
|