Spaces:
Paused
Paused
File size: 666 Bytes
a45aec5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #!/usr/bin/env python3
"""Patch vite.config.ts to set base: '/workspace/' for HF Spaces deployment."""
import sys
path = sys.argv[1] if len(sys.argv) > 1 else 'vite.config.ts'
with open(path, 'r') as f:
content = f.read()
needle = " return {"
replacement = " return {\n base: '/workspace/',"
if "base: '/workspace/'" in content:
print(f"Already patched: {path}")
sys.exit(0)
new_content = content.replace(needle, replacement, 1)
if new_content == content:
print(f"ERROR: Could not find '{needle}' in {path}", file=sys.stderr)
sys.exit(1)
with open(path, 'w') as f:
f.write(new_content)
print(f"Patched {path}: base=/workspace/")
|