Replies: 1 comment 1 reply
-
Currently it's quite involved to intergrade this manually with next.js. You have to modify webpack config accordingly to insert the babel plugin and webpack loader into the right position. If you really have to do this, you can check out craco-plugin-scoped-css to see how it's done. It's very similar. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Install
npm i babel-plugin-react-scoped-css file-loader scoped-css-loader
Create .babelrc
{ "presets": ["next/babel"], "plugins": ["babel-plugin-react-scoped-css"] }
Create .next.config.js
`module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /.scss$/,
use: [
{
loader: isServer ? 'file-loader' : 'style-loader'
},
{
loader: 'css-loader'
},
{ loader: 'scoped-css-loader' },
{
loader: 'sass-loader'
}
]
});
return config;
}
};`
Beta Was this translation helpful? Give feedback.
All reactions