Files
TeleSec/build.py
2025-07-30 21:32:54 +02:00

25 lines
743 B
Python

import json
import os
PREFETCH = ""
VERSIONCO = "2025-07-30_3"
HANDLEPARSE = os.listdir("src/")
ASSETS = json.load(open("_assets.json", "r")) + HANDLEPARSE
for asset in ASSETS:
if asset != "sw.js":
PREFETCH += f'<link rel="prefetch" href="{asset}" />\n'
os.system("rm -r dist ; mkdir -p dist ; cp -r assets/* dist/")
def replace_handles(string):
string = string.replace("%%PREFETCH%%", PREFETCH)
string = string.replace("%%VERSIONCO%%", VERSIONCO)
string = string.replace("%%ASSETSJSON%%", json.dumps(ASSETS, ensure_ascii=False))
return string
for file in HANDLEPARSE:
with open("src/" + file, "r") as f:
out = replace_handles(f.read())
with open("dist/" + file, "w") as f:
f.write(out)