nextjs - 💡(How to fix) Fix Turbopack does not apply PostCSS @value plugin (CSS Modules values are not resolved) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85173Fetched 2026-04-08 02:17:09
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
commented ×2labeled ×2converted_to_discussion ×1issue_type_added ×1

Code Example

import styles from "./page.module.css";
import redStyles from "./redBg.module.css";

export default function Home() {
  return (
    <div className={styles.page}>
      <div className={redStyles.redBg} />
      <div className={styles.greenify}>
        <div className={redStyles.redBg} />
      </div>
    </div>
  );
}

---

@value custom: #0c77f8;

.page {
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  height: 100vh;
}

.greenify {
  opacity: 1; /* otherwise this will be stripped out */
}

---

@value greenify from './page.module.css';
@value custom from './page.module.css';

.redBg {
  height: 100px;
  width: 100px;
  background: custom;
  border: 1px #fff solid;
}

.greenify .redBg {
  background-color: green;
}

---

next dev --webpack

---

/* /src/app/page.module.css */
  
.page_page__ZU32B {
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    height: 100vh;
}

.page_greenify__ESLM3 {
    opacity: 1; /* otherwise this will be stripped out */
}


/* /src/app/redBg.module.css */

.redBg_redBg__7VTYH {
    height: 100px;
    width: 100px;
    background: #0c77f8;
    border: 1px #fff solid;
}

.page_greenify__ESLM3 .redBg_redBg__7VTYH {
    background-color: green;
}

---

next dev

---

/* [project]/src/app/page.module.css [app-client] (css) */
.page-module___8aEwW__page {
  background: black;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  height: 100vh;
  display: flex;
}

.page-module___8aEwW__greenify {
  opacity: 1;
}

/* [project]/src/app/redBg.module.css [app-client] (css) */
.redBg-module__mv2fOq__redBg {
  background: custom;
  border: 1px solid #fff;
  width: 100px;
  height: 100px;
}

.redBg-module__mv2fOq__greenify .redBg-module__mv2fOq__redBg {
  background-color: green;
}

---

Operating System:
  Windows 11 Pro 25H2
  Build 26200.6899
  Windows Feature Experience Pack 1000.26100.253.0

Binaries:
  Node: 22.17.1
  npm: 10.9.2
Relevant Packages:
  next: 16.0.0-canary.16
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/fakkio/next-issue-postcss-modules-values.git

To Reproduce

  1. Create a new Next.js app using create-next-app (App Router, TypeScript).
  2. Add or edit the following files:

src/app/page.tsx

import styles from "./page.module.css";
import redStyles from "./redBg.module.css";

export default function Home() {
  return (
    <div className={styles.page}>
      <div className={redStyles.redBg} />
      <div className={styles.greenify}>
        <div className={redStyles.redBg} />
      </div>
    </div>
  );
}

src/app/page.module.css

@value custom: #0c77f8;

.page {
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  height: 100vh;
}

.greenify {
  opacity: 1; /* otherwise this will be stripped out */
}

src/app/redBg.module.css

@value greenify from './page.module.css';
@value custom from './page.module.css';

.redBg {
  height: 100px;
  width: 100px;
  background: custom;
  border: 1px #fff solid;
}

.greenify .redBg {
  background-color: green;
}
  1. Start the app with Webpack:

    next dev --webpack

    ✅ Rendered page is correct:

    <img width="551" height="386" alt="Image" src="https://github.com/user-attachments/assets/a181c352-1b75-41aa-b348-b064f4f0910d" />

    ✅ Expected CSS is generated correctly:

/* /src/app/page.module.css */
  
.page_page__ZU32B {
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    height: 100vh;
}

.page_greenify__ESLM3 {
    opacity: 1; /* otherwise this will be stripped out */
}


/* /src/app/redBg.module.css */

.redBg_redBg__7VTYH {
    height: 100px;
    width: 100px;
    background: #0c77f8;
    border: 1px #fff solid;
}

.page_greenify__ESLM3 .redBg_redBg__7VTYH {
    background-color: green;
}
  1. Start the app with Turbopack (default):

    next dev

    ❌ Rendered page is wrong:

    <img width="505" height="379" alt="Image" src="https://github.com/user-attachments/assets/1ae9e8fc-14cf-42f4-9d7e-dcd3e376a5bf" />

    ❌ The generated CSS contains unresolved @value tokens, i.e. the custom color is not replaced in rebBg module and the .greenify class is different from the original one in page module:

/* [project]/src/app/page.module.css [app-client] (css) */
.page-module___8aEwW__page {
  background: black;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  height: 100vh;
  display: flex;
}

.page-module___8aEwW__greenify {
  opacity: 1;
}

/* [project]/src/app/redBg.module.css [app-client] (css) */
.redBg-module__mv2fOq__redBg {
  background: custom;
  border: 1px solid #fff;
  width: 100px;
  height: 100px;
}

.redBg-module__mv2fOq__greenify .redBg-module__mv2fOq__redBg {
  background-color: green;
}

Current vs. Expected behavior

Current (Turbopack) @value imports from CSS Modules are not resolved — the literal custom string remains in the final CSS output and the greenify class has a different hash name.

Expected (Webpack) The PostCSS plugin for @value should replace imported constants (e.g., custom) with their actual values (e.g., #0c77f8), and greenify class should match the original one, matching the behavior of the Webpack pipeline.

This affects both dev and build stages.

Provide environment information

Operating System:
  Windows 11 Pro 25H2
  Build 26200.6899
  Windows Feature Experience Pack 1000.26100.253.0

Binaries:
  Node: 22.17.1
  npm: 10.9.2
Relevant Packages:
  next: 16.0.0-canary.16
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

CSS

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

No response

extent analysis

TL;DR

The issue is likely due to the difference in how Webpack and Turbopack handle PostCSS modules, specifically with @value imports, and can be fixed by configuring Turbopack to properly resolve these imports.

Guidance

  • Verify that the PostCSS configuration is correctly set up for Turbopack, ensuring that it can resolve @value imports from CSS Modules.
  • Check the Turbopack documentation for any specific settings or plugins required to support PostCSS modules with @value imports.
  • Consider using a plugin like postcss-modules or postcss-import to help resolve the imports correctly.
  • Test the application with different configurations to isolate the issue and confirm that it's related to the PostCSS module resolution.

Example

No code example is provided as the issue seems to be related to the configuration of Turbopack and PostCSS rather than a specific code snippet.

Notes

The issue might be specific to the version of Next.js or Turbopack being used, and checking the documentation or release notes for any known issues or updates related to PostCSS module support could be helpful.

Recommendation

Apply a workaround by configuring Turbopack to use a PostCSS plugin that supports @value imports, such as postcss-modules, until a more permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING