next.js: styled-jsx: plugins is not a function
What version of Next.js are you using?
10.0.9
What version of Node.js are you using?
15.11.0
What browser are you using?
Chrome, Brave, Firefox
What operating system are you using?
Linux, WIndows, MacOS
How are you deploying your application?
next start
Describe the Bug
When trying to set up styled-jsx to work with sass I get the following error
event - build page: /
wait - compiling...
info - Using external babel configuration from /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/.babelrc
error - ./pages/index.js
TypeError: /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/pages/index.js: plugins is not a function
event - build page: /next/dist/pages/_error
wait - compiling...
error - ./pages/index.js
TypeError: /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/pages/index.js: plugins is not a function
Error: Cannot find module '/home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/.next/server/pages-manifest.json'
Expected Behavior
Project should build with no problem
To Reproduce
Add this to .babelrc
{
"presets": [
[
"next/babel",
{
"styled-jsx": {
"plugins": ["styled-jsx-plugin-sass"]
}
}
]
]
}
Add this to pages/index.js
const backgroundColor = '#eee'
export default function Home() {
return (
<div className="hello">
<p>Hello World</p>
<style jsx>{`
$color: red;
.hello {
background-color: ${backgroundColor};
padding: 100px;
text-align: center;
transition: 100ms ease-in background;
&:hover {
color: $color;
}
@media only screen and (max-width: 480px) {
font-size: 20px;
}
}
`}</style>
</div>
)
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (10 by maintainers)
Commits related to this issue
- Fixed bug where styled-jsx examples don't work because of a wrong plugin (#23414) ## Bug Fixes #23293. Problem was that `styled-jsx-plugin-sass` was used instead of `@styled-jsx/plugin-sass` so it... — committed to vercel/next.js by M1ck0 3 years ago
- Fixed bug where styled-jsx examples don't work because of a wrong plugin (#23414) ## Bug Fixes #23293. Problem was that `styled-jsx-plugin-sass` was used instead of `@styled-jsx/plugin-sass` so it... — committed to SokratisVidros/next.js by M1ck0 3 years ago
I see… Let me check. I’ll get back to you soon.
Could you make a GitHub repo with the issue so I can inspect it further?
Waiting for #23414 to be merged
@M1ck0 thanks, it works using
@styled-jsx/plugin-sass! Shouldn’t we keep this open so it will be fixed in the examples?Use @styled-jsx/plugin-sass instead of
styled-jsx-plugin-sassin.babelrcthen tell me if it works. I’ll reopen it for now until you resolve it.Also, try creating a new project and then adding this config.
@M1ck0 I’m getting this bug as well. Why did you close this issue?