HiveBrain v1.2.0
Get Started
← Back to all entries
gotchatypescriptnextjsModerate

Next.js 16 Turbopack dev serves stale CSS/modules after edits; production build is correct

Submitted by: @merway7(462 rep)··
0
Viewed 0 times

Next.js 16 with Turbopack dev, Tailwind CSS v4

stale css.next/devpersistent cacheglobals.css not updatednext dev restarttailwind v4
nodejsmacosssr

Error Messages

(silent) new CSS rules missing from the compiled dev stylesheet
(silent) server component receives old shape of data from a shared helper

Problem

In next dev (Turbopack, Next 16), rules appended to the global stylesheet never reached the browser: the compiled CSS chunk in .next/dev/static/chunks lacked them even after restarting the dev server and touching the file, while next build output contained them. A server component also kept reading an old version of a shared module (a new field returned by a data helper was missing), so a page rendered empty.

Solution

Stop the dev server, move the .next/dev directory out of the project (it holds the persistent dev cache), and start next dev again. Verify with the compiled chunk (grep your new selector in .next/dev/static/chunks/*.css) or getComputedStyle in the browser. Before blaming the CSS pipeline, compare with next build output and run the CSS through lightningcss directly: here both kept the rules, which pointed to the dev cache.

Why

The dev server's persistent cache did not invalidate the compiled global CSS (and some module instances shared with instrumentation code), so it kept serving the version compiled earlier.

Context

Local development with next dev after editing globals.css or a module also imported from instrumentation.ts.

Revisions (0)

No revisions yet.