`nitro build` silently deletes a `publicAssets` dir that sits inside the output dir
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- build-system
Research direction
Start with the reproduction using the shown nitro.config.ts and npx nitro build, then read src/build/prepare.ts:4-12 and the call site in src/build/vite/plugin.ts:371. The work is done when a publicAssets directory inside a directory scheduled for cleanup cannot be silently deleted, and the build either warns or fails as specified.
Written by the indexing model from the issue text.
Description
nitro build calls prepare(), which rm -rfs the output dirs, before copyPublicAssets(). If a publicAssets dir lives inside one of them (e.g. dist/client with netlify or cloudflare-pages, which publish from dist/), it gets deleted. copyPublicAssets() then skips the missing dir without a warning and the build reports success.
Repro
// nitro.config.ts
import { defineConfig } from "nitro";
export default defineConfig({
preset: "netlify",
publicAssets: [{ dir: "dist/client" }],
});
npm i [email protected]
mkdir -p dist/client && echo 'console.log(1)' > dist/client/app.js
npx nitro build # ✔ Generated public dist
find dist -type f # dist/_headers, dist/_redirects (app.js is gone)
Expected: the build fails, or at least warns, that dist/client is inside a dir that gets cleaned.
Actual: dist/client is deleted and the build succeeds with no client assets.
Versions: nitro 3.0.260903-beta and nitro-nightly 3.0.1-20260928-103646-f72e2ba6. main at 9cf83c8 hasn't changed these files since.
Possible fix: in prepare() (src/build/prepare.ts:4-12), throw if any publicAssets[].dir is inside a dir it's about to remove. nitro/vite isn't affected because it runs prepare() before any environment builds (src/build/vite/plugin.ts:371).
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 905
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 54
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
nitrojs/nitro#4611 · 1 comment ·
Maintainers usually reply within 1 day
-
bug v2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
nitrojs/nitro#4555 · 5 comments ·
Maintainers usually reply within 1 day
-
v2 v3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
v3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nitrojs/nitro#4415 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
supabase/agent-skills#611 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
polka-codes/test#345 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
GoogleChromeLabs/project-sesame#217 ·
Maintainers usually reply within 12 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
solana-foundation/solana-com#2202 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100