Closed mattjennings closed 2 years ago
Bump!
Seems strange that there isn't support since this is a Vercel project and Next.js is now using SWC. I personally want to be able to use scss syntax in my project.
cc @kdy1 @kwonoj
Do you mean a rust-based one, or postcss?
Upvote, the current example for enabling styled jsx plugins is by using it with babel, and there's no clear instruction of how to configure it to work with swc.
PostCSS support for SWC would enable Tailwind CSS usage, like the @apply
directive.
Bumping too... Still no way to use PostCSS + Styled JSX with SWC 😞
The project is halfway through, also using Tailwind and @apply
, so if we need to drop PostCSS, it means we lose that too. So Styled JSX might be the one that goes, if we can find another solution. Or accept slower compilation time...
This is definitely blocking my usage of SWC. I can't imagine having to go back to plain CSS for all my components... that seems so incredibly backwards.
https://swc.rs/docs/configuration/compilation#jscexperimentalplugins might be sth you're looking for
https://swc.rs/docs/configuration/compilation#jscexperimentalplugins might be sth you're looking for
I'm having a hard time using that plugin. As far as I can tell, .swcrc doesn't load in Next.js. As such, i've tried adding the plugin to the experimental swcPlugins section in next.config.js. I've run npm install @swc/plugin-styled-jsx
and confirmed it exists in node-modules.
next.config.js
experimental: {
swcPlugins: [
['@swc/plugin-styled-jsx', {}]
]
}
The above configuration throws "Failed to create plugin instance"
Any insights would be appreciated. Would like to avoid babel + styled-jsx-plugin-postcss.
@Garett-MacGowan if you’re using nextjs, you don’t need to configure swcrc for styled-jsx. Which nextjs version are you having issue with?
@huozhi we actually do need to since tailwind isnt available in styled-jsx without configuring postcss
my current .swcrc config
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"experimental": {
"plugins": [
[
"@swc/plugin-styled-jsx",
{
"plugins": [
"@styled-jsx/plugin-sass",
"styled-jsx-plugin-postcss"
]
}
]
]
}
}
}
I would say this is more like a limitation to swc while supporting various usage cases. swc compilation for next.js (next-swc) can have native and wasm bindings to run in different scenarios. Supporting many pre-processing plugins which are depending on node.js (like sass) would be a problem for wasm build of next-swc. Also it could have a performance limitation which is opposite to the purpose of having swc compilation.
At the moment we don't have an nice solution to handle it in both ways, going to close this issue for now.
@huozhi we actually do need to since tailwind isnt available in styled-jsx without configuring postcss
my current .swcrc config
{ "$schema": "https://json.schemastore.org/swcrc", "jsc": { "experimental": { "plugins": [ [ "@swc/plugin-styled-jsx", { "plugins": [ "@styled-jsx/plugin-sass", "styled-jsx-plugin-postcss" ] } ] ] } } }
Have you got it working with style-jsx + tailwind(postcss)?
@huozhi
swc compilation for next.js (next-swc) can have native and wasm bindings to run in different scenarios. Supporting many pre-processing plugins which are depending on node.js (like sass) would be a problem for wasm build of next-swc.
Starting with Next 14, the WASM target for next-swc
has been removed.
At the moment we don't have an nice solution to handle it in both ways, going to close this issue for now.
If I understand this right, now that we don't have to handle it both ways, this issue can be reopened (or a new one could be created).
so any updates on this? cuz this is bad:
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
It seems there is currently no support for plugins when using SWC with Next.js. Are there any plans for this? I'd really like to setup PostCSS, but of course it's only available as a babel plugin.
If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar
What is the expected behavior?
Plugin system to allow CSS preprocessing
Environment (include versions)
Did this work in previous versions?
Yes, plugin system is available with Babel