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.

@apply not working with styled-jsx (Next.js v10, Tailwind v2)

See original GitHub issue

There is another bug already about this (#1234), but it is closed as it seems like a solution was found for previous versions. I am using the new Tailwind v2 and I’ve tried some of the configurations listed in the issue’s comments but none have worked for me. Maybe there’s something wrong with my setup, but I’m posting as a new bug just in case it’s related to Tailwind v2.

Relevant configs

// .babelrc
{
  "presets": [
    [
      "next/babel",
      {
        "styled-jsx": {
          "plugins": ["styled-jsx-plugin-postcss"]
        }
      }
    ]
  ]
}
// postcss.config.js
module.exports = {
  plugins: ['tailwindcss', 'autoprefixer']
}
// deps (package.json)
{
  "dependencies": {
    "bluebird": "^3.7.2",
    "classnames": "^2.2.6",
    "next": "10.0.2",
    "next-mdx-remote": "^1.0.0",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  },
  "devDependencies": {
    "@types/bluebird": "^3.5.33",
    "@types/classnames": "^2.2.11",
    "@types/node": "^14.14.9",
    "@types/react": "^17.0.0",
    "autoprefixer": "^10.0.2",
    "gray-matter": "^4.0.2",
    "postcss": "^8.1.8",
    "styled-jsx-plugin-postcss": "^3.0.2",
    "tailwindcss": "^2.0.1",
    "typescript": "^4.1.2"
  }
}

Errors that I’m getting

wait  - compiling...
[styled-jsx] Loading plugin from path: /home/dani/projects/daniguardiola-me/node_modules/styled-jsx-plugin-postcss/index.js
Next.js 9 default postcss support uses a non standard postcss config schema https://err.sh/next.js/postcss-shape, you must use the interoperable object-based format instead https://nextjs.org/docs/advanced-features/customizing-postcss-config
Next.js 9 default postcss support uses a non standard postcss config schema https://err.sh/next.js/postcss-shape, you must use the interoperable object-based format instead https://nextjs.org/docs/advanced-features/customizing-postcss-config
error - ./components/Post.tsx
Error: /home/dani/projects/daniguardiola-me/components/Post.tsx: postcss failed with TypeError: Invalid PostCSS Plugin found: [0]
    at Array.forEach (<anonymous>)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
adamwathancommented, Nov 22, 2020

Hey! Please provide a GitHub repo that reproduces the issue so we don’t have to create it from scratch ourselves, we can help much faster if all we need to do is clone a reproduction and see what’s happening.

0reactions
DaniGuardiolacommented, Nov 22, 2020

Of course, if you see something wrong with the Next.js configuration, please let me know. AFAIK, it should be working with the given PostCSS and Babel configs 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Tailwindcss not working with next.js; what is wrong ...
In my case, I had set up the Tailwind config file correctly, but tailwind styles were not applying. Deleting the .next folder and...
Read more >
Build a Full Stack App with Next.js, Tailwind, tRPC and Prisma ...
This is where tRPC comes in, with this toolkit it is possible to create a totally type safe application by only using inference....
Read more >
Toggle Different Components on Click Using Next.js and ...
Hello everyone, I was working on a project where I have two buttons, and when I click one of them, the component changes....
Read more >
Switching to Tailwind CSS - Lee Robinson
Learn why I switched my Next.js blog to use Tailwind CSS and how it ... to v10 ); Tailwind CSS (Switched from Chakra...
Read more >
Get started with Storybook and Next.js
js tutorial app holds global styles in /styles/globals.css . We can import our global stylesheet into our home.stories.jsx story file. But doing ...
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