question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CRA5 app using postcss v8.4.6 fails to build

See original GitHub issue

Describe the bug

(Originally reported as https://github.com/tailwindlabs/tailwindcss/issues/7687, but closed and moved to a discussion as this is not in fact a Tailwind issue, see https://github.com/tailwindlabs/tailwindcss/discussions/7688#discussioncomment-2266946.)

In a vanilla CRA 5 app configured with Tailwind 3, the project fails to build if a CSS rule using Tailwind’s @apply directive together with a background color rule is included. Removing the background color from the custom selector avoids the problem.

Alternatively, the build succeeds without modifying the CSS after downgrading postcss to 8.4.5, suggesting a possible regression in postcss.

Environment

Environment Info:

current version of create-react-app: 5.0.0 running from /Users/stephen/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

System: OS: macOS 12.1 CPU: (10) x64 Apple M1 Pro Binaries: Node: 14.17.5 - /usr/local/bin/node Yarn: 1.22.11 - ~/.npm-global/bin/yarn npm: 8.5.2 - ~/.npm-global/bin/npm Browsers: Chrome: 98.0.4758.109 Edge: Not Found Firefox: 96.0.3 Safari: 15.2 npmPackages: react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 react-scripts: 5.0.0 => 5.0.0 npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

Sample project to reproduce issue: https://github.com/stephent/cra-5-tw-3-build-fails

  1. Download main branch of sample project
  2. Install dependencies npm i
  3. Run npm run build

Expected behavior

Should build successfully

Actual behavior

Build fails with the following error:

Failed to compile.

static/css/main.4bacc579.css from Css Minimizer plugin
Error: Invalid mapping: {"generated":{"line":3,"column":8651},"source":"static/css/main.4bacc579.css","original":{"line":330,"column":null},"name":null}

Reproducible demo

https://github.com/stephent/cra-5-tw-3-build-fails

  • Download source, install dependencies
  • Build project
  • Build fails as described above
  • The project includes a file ./styles/custom.css with a single selector, .my-class. Edit line 2 and delete the applied rule bg-white
  • The project builds successfully
  • I tried a few different rules here and only managed to reproduce the build error when a background color rule was used.

An alternative fix for this problem is to downgrade postcss to version 8.4.5, which allows the project to build successfully. This suggests there’s a regression bug somewhere in 8.4.6.

I could not find any open bug reports against css-minimizer-webpack-plugin for ‘Invalid mapping’ errors, and given that CRA doesn’t expose webpack config by default, I wonder if there’s an issue with what gets passed in to the css minimizer.

See also

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
aicommented, Mar 7, 2022

One moment! I will try to fix it today.

2reactions
thecrypticacecommented, Mar 7, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tailwind CSS classes not updating after initial build of react app
With the upgrade to V3 I ran the command npx tailwindcss init. The problem was I ran it inside the src folder so...
Read more >
Guide to Creating a React App 5 - Airo Global Software
Details on the new features and packages in CRA 5 ... Create-react-app will fail if the node version does not meet the requirement....
Read more >
How to setup Tailwind 3 in React with CRA 5 ? - GeeksforGeeks
Create React App: Helps us to create single-page React applications without ... Step 3: Install Tailwind, PostCSS, and Autoprefixer in your given directory....
Read more >
How to Migrate From Create-React-App 4 to 5 - YouTube
The team behind Create -React- App updated the package from version 4 to 5. I'll go over how to migrate a react application...
Read more >
Postcss Postcss Statistics & Issues - Codesti
Issue Title State Comments Created Date Updated... node_modules/postcss/lib/processor.es6:139:15 closed 1 2022‑11‑30 2022‑12... do i need `postcss‑flexbugs‑fixes`? closed 1 2022‑11‑23 2022‑12... How to use `postcss.parse` with plugins...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found