-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS modules #270
Comments
We're having this problem too, but with PostCSS. Any help here is appreciated. |
Is it possible to send me a sample repo, I can work with this. |
seems like when I use this loader setup in my app's webpack config: {
test: /\.css?$/,
loaders: [ 'style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' ],
include: path.resolve(__dirname, '../')
},
{
test: /\.scss$/,
loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!sass-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
include: path.resolve(__dirname, '../')
} and the same in storybooks webpack: {
test: /\.css?$/,
loaders: [ 'style', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' ],
include: __dirname
},
{
test: /\.scss$/,
loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!sass-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
include: __dirname
} Then CSS modules works from both plain .css files and also from .scss files. Or check commit: michaltakac/react-storybook-demo@aa13f1d |
Thansk @michaltakac for the sample. |
This solution seems to not work anymore. I'm having trouble getting CSS modules (specifically, React CSS Modules) to work within Storybook. Steps:
|
+1 |
I am having the same issue here. I can't make it work with css modules. |
Look here. Work Fine |
I got it to work, thanks. Just for future reference, if you want to just add css modules to your react storybook project:
|
Guys (particularly @arunoda), do you have any clue what I could be doing wrong here? Styles from CSS Modules don't show up in the storybook despite the solution you've provided above. I've officially run out of ideas.
|
Not working at all |
Since webpack released version 2.0, I think it might have affected how css modules settings work. |
For webpack 2 I'm using this in module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
],
},
} |
@MacroWorms It works like a charm. Thank you for updating the solution. |
@MarcoWorms works as of Nov 10th, thanks for sharing! |
The upcoming version of https://github.com/facebook/create-react-app (v2) will have support for css-modules. How could storybook detect that? |
@MarcoWorms works for me as of Aug. 2nd. Thanks! |
the above is invalid as of Feb. 2019. |
I had similar issues and this config ended up working for me.
|
Thanks @madhudskumar! Installing |
Hi, I'm trying to use SASS styles like this in my React components:
Styles are working in my app normally, all good. But when I open them in storybook, styles won't show up. Is this problem with my webpack setup for storybook? Here is how it looks like:
If I import styles with
import './sidebar.scss' ;
and then write class names explicitly into classNames, then styles are used correctly in storybook (so SASS files are loaded without problem, loaders in webpack works).What should I do if I want to use styles like I shown in my Sidebar component on top of this comment?
The text was updated successfully, but these errors were encountered: