next.js: Next 6 breaks styled-jsx with sass plugin
- [X ] I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Should be able to upgrade next 6 and still use styled-jsx with sass
Current Behavior
Working with next 5.1.0 upgrading to next 6 breaks importing a scss file to be used in styled-jsx example
import style from ‘./componentName.scss’;
in component: <styled jsx>{style}</style>
On next 6 I get ‘style is undefined’
package.json “extract-text-webpack-plugin”: “^3.0.2”, “extracted-loader”: “^1.0.3”, “node-sass”: “^4.7.2”, “postcss”: “^6.0.16”, “postcss-cssnext”: “^3.0.2”, “postcss-loader”: “^2.0.10”, “sass-loader”: “^6.0.6”, “styled-jsx-css-loader”: “^0.3.0” “styled-jsx-plugin-sass”: “^0.2.2”, “autoprefixer”: “^8.2.0”,
babelrc
"presets": [
[
"next/babel",
{
"preset-env": { "modules": "commonjs" }
}
]
],
"plugins": [
[
"styled-jsx/babel",
{ "plugins": [
["styled-jsx-plugin-sass", {
"sassOptions": {
"includePaths": ["./styles"],
"precision": 2
}
}
]
]
}
]
]
}
```
next.config.js
```const ExtractTextPlugin = require('extract-text-webpack-plugin');
const dev = process.env.NODE_ENV !== 'production';
const path = require('path');
const getRoutes = require('./routes');
module.exports = {
exportPathMap: getRoutes,
webpack: (config) => {
config.module.rules.push({
test: /\.scss$/,
use: [
{
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]',
},
},
'babel-loader',
'styled-jsx-css-loader',
'postcss-loader',
],
});
return config;
},
};```
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
| Tech | Version |
|---------|---------|
| next | 6 |
| node | 8.10.0 |
| OS | mac and windows |
| browser | |
| etc | |
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 3
- Comments: 22 (9 by maintainers)
Commits related to this issue
- narrow down the problem, remove unnecessary packages https://github.com/zeit/next.js/issues/4265#issuecomment-393494504 — committed to blackbing/next-with-jest-style-jsx-error by blackbing 8 years ago
- add styled-jsx preset-env test https://github.com/zeit/next.js/issues/4265#issuecomment-393835058 — committed to blackbing/styled-jsx by blackbing 8 years ago
You may check this package: https://github.com/zeit/next-plugins/tree/master/packages/next-sass
@giuseppeg it looks pass. https://github.com/blackbing/styled-jsx/commit/0feb15f5be267571583a459033bdb6696cef9c80 or do I miss something?
Awesome, I’ll just close this. If it doesn’t work feel free to provide a full reproduction.
Thank you for verifying @codinronan @blackbing! ❤️
I have same problem. and @timneutkens point out my problem. check out this.: https://github.com/zeit/next.js/issues/4239#issuecomment-392468298
If you use
babel-nodecheck out this: https://github.com/zeit/next.js/issues/4239#issuecomment-392515782thanks to @timneutkens