rqbit/crates/librqbit/webui/post-build

27 lines
No EOL
636 B
Python
Executable file

#!/usr/bin/env python3
import os
import json
import re
os.chdir('dist')
with open('manifest.json', 'r') as f:
manifest = json.load(f)
# For rust to "include_str!", we need to have predictable filenames.
# So strip all hashes out of the generated files.
with open('index.html', 'r') as f:
index_html = f.read()
for key, item in manifest.items():
generated_file = item['file']
new_file = re.sub(r'^(assets/.+)-.+(\..+)$', r'\1\2', generated_file)
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)