fix(build): fix WASM 404 in production by creating symlinks in wasm/ directory
This commit is contained in:
parent
88cd23f74f
commit
aebdcd6d99
3
Makefile
3
Makefile
@ -5,6 +5,9 @@ build:
|
|||||||
@$(MAKE) highlight-css
|
@$(MAKE) highlight-css
|
||||||
@tailwindcss -i input.css -o public/style.css --minify
|
@tailwindcss -i input.css -o public/style.css --minify
|
||||||
@dx build --release
|
@dx build --release
|
||||||
|
@echo "Fixing WASM paths for production..."
|
||||||
|
@python3 scripts/fix-wasm-paths.py
|
||||||
|
@echo "WASM paths fixed."
|
||||||
|
|
||||||
highlight-css:
|
highlight-css:
|
||||||
@cargo run --bin generate_highlight_css
|
@cargo run --bin generate_highlight_css
|
||||||
|
|||||||
48
scripts/fix-wasm-paths.py
Executable file
48
scripts/fix-wasm-paths.py
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Fix WASM paths for Dioxus production builds.
|
||||||
|
|
||||||
|
Dioxus 0.7 hashes WASM/JS files and places them in assets/, but index.html
|
||||||
|
still references the old wasm/ paths. This script creates symlinks to bridge
|
||||||
|
the gap.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
manifest_path = "target/dx/yggdrasil/release/web/.manifest.json"
|
||||||
|
|
||||||
|
if not os.path.exists(manifest_path):
|
||||||
|
print("Manifest not found, skipping WASM path fix")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
with open(manifest_path) as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
wasm_dir = "target/dx/yggdrasil/release/web/public/wasm"
|
||||||
|
assets_dir = "target/dx/yggdrasil/release/web/public/assets"
|
||||||
|
os.makedirs(wasm_dir, exist_ok=True)
|
||||||
|
|
||||||
|
for path, info_list in data["assets"].items():
|
||||||
|
if "wasm/" in path:
|
||||||
|
for info in info_list:
|
||||||
|
bundled = info["bundled_path"]
|
||||||
|
original_name = os.path.basename(path)
|
||||||
|
src = os.path.join(assets_dir, bundled)
|
||||||
|
dst = os.path.join(wasm_dir, original_name)
|
||||||
|
|
||||||
|
if os.path.exists(src):
|
||||||
|
if os.path.islink(dst) or os.path.exists(dst):
|
||||||
|
os.remove(dst)
|
||||||
|
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
||||||
|
print(f"Linked: wasm/{original_name} -> assets/{bundled}")
|
||||||
|
else:
|
||||||
|
print(f"ERROR: Source not found: {src}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user