Next.js codegen now imports project CSS from _app.tsx / app/layout.tsx
Update 2026-06-03
We’ve re-released the change where Next.js codegen imports your project’s global CSS directly from your root entry file (pages/_app.tsx or app/layout.tsx), available in @plasmicapp/cli 0.1.364 (or later).
A bit of context: we originally shipped this change a little while ago and temporarily reverted it (see the previous announcement) after some users reported that imported (hostless) dependency styles weren’t regenerating correctly. On further investigation this turned out to be a false positive; the change itself was working as intended. The dependency styles simply hadn’t been fully regenerated because the sync was run without the --force and --all-files flags. With those flags, everything regenerates correctly, so we’ve re-released the change.
Announcement
We have an important change rolling out in the next @plasmicapp/cli release that affects Next.js customers using the codegen scheme.
What’s changing
Previously, your project’s css lived in a file like:
components/plasmic/<project>/plasmic.module.css
That file was a CSS Module, scoped per-file. Going forward, that same file is emitted as a non-module global CSS:
components/plasmic/<project>/plasmic.css
Because the project CSS file is now global CSS, Next.js requires it to be imported from a single place; the app’s root entry file:
-
Pages Router →
pages/_app.tsx -
App Router →
app/layout.tsx
On the next sync, the CLI will add this import for you automatically, but only if one of the root files above already exists in your project. If neither is present (e.g., you’ve renamed _app.tsx or moved app/layout.tsx), you’ll need to add the import yourself. The line looks like:
import "../components/plasmic/<project>/plasmic.css"; // plasmic-import: <projectId>/projectcss
Why Next.js requires this
Next.js enforces a strict rule that non-module global CSS imports are only allowed in the root entry file. Importing global CSS from any other component throws a build error.
This is why the import has to go in _app.tsx (Pages router) or app/layout.tsx (App router) specifically.
What you need to do
-
Update
@plasmicapp/clito the new version (0.1.364 or later) -
Run
plasmic sync --force --all-files
These flags are important: they ensure your project and all of its imported dependencies (e.g. hostless projects likeantd5) regenerate with the correct styles. A plainplasmic syncmay leave dependency CSS files stale.
The CLI will:
-
Rename
plasmic.module.css→plasmic.css(and updateplasmic.json). -
Add the project global CSS import lines to your root entry file.
Edge cases
- If your project doesn’t follow the default Next.js convention (e.g., you renamed
pages/_app.tsxto something else, or yourapp/layout.tsxis missing or lives elsewhere), the CLI may not find your root file. You’ll need to add the import manually.
If you hit anything unexpected, drop a reply on this thread or open an issue. Thanks!