Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
CSS Media Query Compilation Issue | GoodFirstPicks

CSS Media Query Compilation Issue

vercel/next.js 1 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeTest focusedNext.jsTypeScriptReact

Why this is a good first issue

CSS media query compilation issue involving a specific PostCSS plugin bug.

AI Summary

The issue involves a bug in the CSS media query compilation process where parentheses are incorrectly dropped in `not` expressions. This requires understanding PostCSS and CSS Media Queries Level 4 syntax. The fix likely involves updating or patching the PostCSS plugin, but the exact scope depends on Next.js's internal PostCSS configuration.

Issue Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/fragrant-sky-dkr6k9

To Reproduce

Prerequisites

  • Node.js 18+ and yarn installed
  • Spirit Design System package (@alma-oss/spirit-web) that uses modern CSS media query range syntax

Steps to reproduce

  1. Create a new Next.js 16.1.5 project
npx [email protected] nextjs-media-query-bug
cd nextjs-media-query-bug
  1. Install Spirit Design System
yarn add @alma-oss/[email protected]
  1. Create a minimal PostCSS config:
// postcss.config.mjs

export default {
  plugins: {
    autoprefixer: {
      flexbox: 'no-2009',
    },
  },
};
  1. Import Spirit CSS utilities:
// app/globals.css

@import '@alma-oss/spirit-web/css/utilities.css';
  1. Create a test page at:
// app/page.tsx

export default function Home() {
  return (
    <div className="d-only-tablet-none">
      This should be hidden on tablet (768px-1279px)
    </div>
  );
}
  1. Build the application
yarn build

Current vs. Expected behavior

IMO, Next.js 16.1.5 bundles postcss-preset-env v7.4.3 internally, which uses @csstools/postcss-media-minmax to transpile CSS Media Queries Level 4 range syntax. The bundled version has a bug where it drops the outer parentheses around not expressions when combined with and operators, violating the CSS Media Queries Level 4 specification.

The CSS code before postprocessing:

@media (width >= 768px) and (width < 1280px) { … }

Current behavior after postprocessing.

 @media (min-width: 768px) and not (min-width: 1280px) { ... }

Expected behavior after postprocessing.

 @media (min-width: 768px) and (not (min-width: 1280px)) { ... }

Alternative solutions

Media Qu

GitHub Labels

CSS

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • CSS parsing edge case
  • dependency version conflict
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes