Build failure: CSS file missing in SSR bundle (`style.css` not emitted)
#1,346 opened on 2026年5月20日
Repository metrics
- Stars
- (8,120 stars)
- PR merge metrics
- (平均マージ 1d 1h) (30d で 462 merged PRs)
説明
This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-20).
Problem
The SSR bundle's index.js contains an import './style.css' statement, but the CSS file is not emitted to dist/server/ssr/. The build succeeds, but the production server crashes during prerendering when Node.js tries to resolve the .css import.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
'/tmp/.../dist/server/ssr/style.css'
imported from /tmp/.../dist/server/ssr/index.js
CSS imports in SSR builds should either be stripped (since CSS is injected client-side) or the CSS file should be emitted alongside the SSR bundle.
Estimated Impact
~5 test failures (1 runtime crash, 5 failed assertions).
Affected Test Suites
test/e2e/react-version/react-version.test.ts(5 failures)
Recommendation
-
Reproduce first in vinext's own test suite. Add a test that imports CSS in a component and verify the SSR build doesn't crash during prerendering. Confirm it fails.
-
Strip or emit CSS in SSR builds. Either configure the SSR build to strip CSS imports (replace with empty modules) or ensure CSS files are properly emitted to the SSR output directory. Study how
@vitejs/plugin-rscand Vite handle CSS in SSR environments. -
Check the Vite SSR build configuration. The
build.rolldownOptionsfor the SSR environment may needcsshandling configuration.