fix: serve module .mjs chunks and CSS via MapStaticAssets#94
Merged
antosubash merged 1 commit intomainfrom Apr 8, 2026
Merged
Conversation
Production was hitting two categories of asset 404s:
1. Code-split .mjs chunks from module Vite builds (e.g. Users/Login)
were silently dropped from the StaticWebAssets endpoint manifest
because .mjs is not in the SDK's default content-type mappings. A
previous UseStaticFiles fallback couldn't reach RCL _content/ paths,
so the browser got a hard 404 and login broke.
Fix: register .mjs as text/javascript via StaticWebAssetContentTypeMapping
in Directory.Build.props. MapStaticAssets now emits an endpoint per
.mjs file with fingerprinting and compression for free. The fallback
middleware in SimpleModuleHostExtensions is removed.
2. resolve-page.ts speculatively injected a <link> tag for every
navigated module, which 404'd for every module without CSS and
polluted the console with strict-MIME warnings.
Fix: discover module CSS server-side. HtmlFileInertiaPageRenderer
walks WebRootFileProvider(\"_content\") once at startup and injects
<link> tags for every module that ships its own {assembly}.css into
a new <!--MODULE_CSS_LINKS--> placeholder in index.html. The client
resolver no longer touches CSS at all.
Supporting changes:
- .dockerignore excludes module wwwroot build outputs and .vite caches
so stale local artifacts can't be baked into images.
- Makefile clean now scrubs Vite outputs (emptyOutDir is false, so Vite
never clears them itself), plus new clean-run, docker-build-nocache,
and docker-clean-run convenience targets.
Deploying simplemodule-website with
|
| Latest commit: |
f30dd91
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5b990a45.simplemodule-website.pages.dev |
| Branch Preview URL: | https://feature-tender-heisenberg.simplemodule-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Static Asset Configuration
.mjs(ES module chunks from Vite code-splitting) inDirectory.Build.propssoMapStaticAssetsincludes them in the manifestUseStaticFilesmiddleware that was masking the core issueModule CSS Injection
BuildModuleCssLinks()toHtmlFileInertiaPageRendererto auto-discover and inject<link>tags for module CSS files at startup<!--MODULE_CSS_LINKS-->placeholder inindex.htmlresolve-page.ts(now handled at render time)Build & Deployment
.dockerignoreto exclude Vite output directories and.vitecaches to prevent stale artifactsdocker-build-nocacheanddocker-clean-runMakefile targetscleantarget to remove module wwwroot outputs, ClientApp bundle, and Vite cachesclean-runtarget for development workflowDependencies
rolldownand@oxc-project/typesto rc.13viteto 8.0.7