From 8bf05a0127010e965c16468fe3f3c30d3bbac0c6 Mon Sep 17 00:00:00 2001 From: fry69 <142489379+fry69@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:54:04 +0100 Subject: [PATCH] docs: add clarification for assets/static (#3525) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a short clarification how imported assets vs. static files get handled now with Vite to the existing documentation for static files. --------- Co-authored-by: Bartek IwaƄczuk Co-authored-by: Claude Opus 4.6 (1M context) --- docs/latest/concepts/static-files.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/latest/concepts/static-files.md b/docs/latest/concepts/static-files.md index 45791833..aabb6d07 100644 --- a/docs/latest/concepts/static-files.md +++ b/docs/latest/concepts/static-files.md @@ -16,6 +16,32 @@ const app = new App() .use(staticFiles()); ``` +## Imported assets vs static files + +When using Fresh with Vite (now the default), **files that you import in your +JavaScript/TypeScript code should not be placed in the `static/` folder**. This +prevents file duplication during the build process. + +```tsx +// Don't import from static/ +import "./static/styles.css"; + +// Import from outside static/ (e.g., assets/) +import "./assets/styles.css"; +``` + +**Rule of thumb:** + +- Files **imported in code** (CSS, icons, etc.): place outside `static/` (e.g., + in an `assets/` folder) +- Files **referenced by URL path** (favicon.ico, fonts, robots.txt, PDFs, etc.): + place in `static/` + +When you import a file in your code, Vite processes it through its build +pipeline, optimizes it, and adds a content hash to the filename for cache +busting. Keeping these files outside `static/` ensures they're only included +once in your build output. + ## Caching headers By default, Fresh adds caching headers for the `src` and `srcset` attributes on