Fix: don't copy 9 GB data dir into dist/ during production builds

BINCIO_DATA_DIR is already set in the build env, so manifest.ts reads
the data root directly at build time without needing public/data.
Moving _link_data() into the serve-only branch prevents Astro from
following the symlink and copying the full data dir into dist/. Any
leftover symlink from a previous dev session is removed before build.
Dev mode is unchanged.
This commit is contained in:
Davide Scaini
2026-05-08 13:56:31 +02:00
parent 2287d6e2ee
commit 55d59112ad
+9 -1
View File
@@ -201,15 +201,23 @@ def render(
return
_ensure_npm(site)
_link_data(site, data)
env = {**os.environ, "BINCIO_DATA_DIR": str(data)}
if serve:
# Dev server needs to serve /data/ files at runtime from public/
_link_data(site, data)
console.print("Starting [cyan]astro dev[/cyan]…")
subprocess.run(["npm", "run", "dev"], cwd=site, env=env)
return
# Production build: BINCIO_DATA_DIR is already set so manifest.ts reads
# data directly; remove any leftover public/data symlink so Astro doesn't
# copy the full data directory (9+ GB) into dist/.
public_data = site / "public" / "data"
if public_data.is_symlink():
public_data.unlink()
# Build
cmd = ["npm", "run", "build"]
if out_dir: