33 lines
No EOL
791 B
Python
Executable file
33 lines
No EOL
791 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import os.path
|
|
import json
|
|
import re
|
|
import itertools
|
|
|
|
os.chdir('dist')
|
|
|
|
with open(os.path.join('.vite', '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 dst, src in [
|
|
("assets/logo.svg", manifest["assets/logo.svg"]["file"]),
|
|
("assets/index.css", manifest["index.html"]["css"][0]),
|
|
("assets/index.js", manifest["index.html"]["file"])
|
|
]:
|
|
generated_file = src
|
|
new_file = dst
|
|
|
|
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) |