Skip to content

feat: support multiple staticDir entries#3759

Merged
bartlomieju merged 6 commits into
mainfrom
feat/multiple-static-dirs
Apr 9, 2026
Merged

feat: support multiple staticDir entries#3759
bartlomieju merged 6 commits into
mainfrom
feat/multiple-static-dirs

Conversation

@bartlomieju
Copy link
Copy Markdown
Contributor

@bartlomieju bartlomieju commented Apr 8, 2026

Summary

  • staticDir now accepts string | string[] in both the Vite plugin (FreshViteConfig) and the Builder API (BuildOptions)
  • When multiple directories are specified, they are searched in order and the first match wins
  • Vite plugin: first dir maps to Vite's native publicDir; extra dirs are served manually in the dev server and walked during production builds
  • Builder API: both MemoryBuildCache (dev) and DiskBuildCache (prod) iterate over all directories
  • Updated tailwind v3 plugin to use config.root instead of path.dirname(config.staticDir)
  • Docs updated: static-files.md, vite.md, builder.md

Closes #3105

Test plan

  • All 66 Vite plugin tests pass (dev + build)
  • All 28 Builder + build cache tests pass
  • New test: Builder - multiple staticDir in dev — serves files from both dirs, first-dir-wins for conflicts
  • New test: Builder - multiple staticDir in prod — same behavior in production builds

🤖 Generated with Claude Code

bartlomieju and others added 6 commits April 8, 2026 19:35
Allow `staticDir` to accept an array of directories. When multiple
directories are specified, they are searched in order and the first
match wins. This is useful for separating generated assets from
hand-authored static files.

Closes #3105

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend the Vite plugin with the same staticDir array support added to
the Builder API. The first directory maps to Vite's native publicDir;
extra directories are served manually in the dev server and walked
during production builds with first-match-wins semantics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CI typo checker flags "Pn" as a misspelling of "On".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Windows runners were occasionally timing out at 10 minutes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju enabled auto-merge (squash) April 9, 2026 07:48
@bartlomieju bartlomieju merged commit 990aeb0 into main Apr 9, 2026
9 checks passed
@bartlomieju bartlomieju deleted the feat/multiple-static-dirs branch April 9, 2026 07:49
bartlomieju added a commit that referenced this pull request Apr 27, 2026
- Bump `@fresh/core` to `2.3.1`
- Bump `@fresh/init` to `2.3.1`
- Bump `@fresh/update` to `2.3.1`
- Bump `@fresh/plugin-vite` from `1.0.8` to `1.1.0`
- Bump `@fresh/plugin-tailwind-v3` from `1.0.1` to `1.1.0`

The plugin packages were not published during the 2.3.0 release despite
having significant changes merged. Notable fixes in `@fresh/plugin-vite`
include immutable caching for Vite-built assets (#3761), CSS modules in
layouts (#3764), and multiple `staticDir` support (#3759).

Also updates `FRESH_VITE_PLUGIN` version constant in `@fresh/init` so
new projects scaffold with the correct plugin version.

Closes #3784
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple staticDir entries in config

1 participant