vercel / vercel/next.js

Webpack mangles `@import ... supports(...)` syntax when inlining CSS

Open
#89,602 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CSS Webpack
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/robert-j-webb/nextjs-repro-webpack-import-supports-css

To Reproduce

Clone repo, npm install.

Run

npm run build && npm run start

or

npm run dev

Go to localhost:3000

Observe the h1 is blue.

Additionally, observe the CSS in the network tab of the inspector

@media supports(display: flex) {
    h1 {
        color:rgb(255,0,0)!important
    }
}

h1 {
    color: rgb(0,0,255)
}
Current vs. Expected behavior

The H1 should be red.

The CSS should look like (Notice that @media supports -> @supports)

@supports(display: flex) {
    h1 {
        color:rgb(255,0,0)!important
    }
}

h1 {
    color: rgb(0,0,255)
}

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:34:00 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T8132
  Available memory (MB): 24576
  Available CPU cores: 10
Binaries:
  Node: 24.10.0
  npm: 11.6.1
  Yarn: 1.22.22
  pnpm: 10.28.0
Relevant Packages:
  next: 16.2.0-canary.29 // Latest available version is detected (16.2.0-canary.29).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

CSS, Webpack

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

next build (local), next dev (local)

Additional context

I found this while fixing Turbopack support for the @import url in https://github.com/vercel/next.js/pull/89300

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone the linked reproduction repository, run npm install, then use npm run build && npm run start or npm run dev and inspect localhost:3000 and the CSS in the browser network tab. Trace the Webpack CSS inlining path from this reproduction; done means @import ... supports(...) remains an @supports block and the H1 renders red.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, webpack
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.