Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`nitro build` silently deletes a `publicAssets` dir that sits inside the output dir

Open Beginner friendly
#4,679 0 comments 0 reactions 0 assignees View on GitHub

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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nitrojs/nitro

All issues in nitrojs/nitro

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.