rqbit/crates/librqbit/webui/post-build

27 lines
636 B
Text
Raw Normal View History

#!/usr/bin/env python3
import os
import json
2023-11-27 17:21:45 +00:00
import re
os.chdir('dist')
with open('manifest.json', 'r') as f:
manifest = json.load(f)
2023-11-27 17:21:45 +00:00
# For rust to "include_str!", we need to have predictable filenames.
# So strip all hashes out of the generated files.
2023-11-27 17:21:45 +00:00
with open('index.html', 'r') as f:
index_html = f.read()
2023-11-27 17:21:45 +00:00
for key, item in manifest.items():
generated_file = item['file']
new_file = re.sub(r'^(assets/.+)-.+(\..+)$', r'\1\2', generated_file)
2023-11-27 17:21:45 +00:00
index_html = index_html.replace("/" + generated_file, new_file)
os.rename(generated_file, new_file)
with open('index.html', 'w') as f:
f.write(index_html)