-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
Modules names added but CSS isn't generated #132
Comments
Have you gotten this to work? |
Check to make sure your css-loader is using the same |
No. I never got this working, but I actually ended up replacing CSS Modules with Styled Components which greatly reduced the amount of boilerplate I was writing related to styling. |
I think you can fix this with the following config in webpack:
The important part is the query string after css-loader. The I don't think this is made obvious in the docs. |
Experience the same issue, tried the approach @dmeehan1968 and @shawnmclean mentioned here but still not able to get it work. The root cause is this: Even if we are using the same The version in <style> tag is wrapped with weird hypen, for example:
Any idea why there is a hypen-wrapper? |
@kavare Can you post the relevant bits of your webpack/babel config? |
@kavare I changed from using the query string format to the JSON format which is a bit clearer:
I've subsequently added |
Here's my config (without postcss, with sass-loader)
|
Found the issue: So instead of this: Do this: Maybe just a quirk from
Thank you @dmeehan1968 for providing the inspiration :) |
I don't think the quotes are necessary on a query string (its effectively a URI) and css-loader has converted them to hyphens to make them in to a valid CSS class name. The behaviour seems sane, and I suspect that the query string format is historical from when webpack didn't take options for plugins. Plus the JSON format is much more readable! Glad you sorted it :-) |
Thanks @dmeehan1968 and @kavare for solving this problem for me :). Btw it would be great to mention in the documentation that the css-loader's option localIdentName has to be configured this particular way, because right now there is only "Note: The default configuration should work out of the box with the css-loader." which sounds like there is no need to configure anything else. |
I'm still having this issue. The random base64 hash is not the same. |
I'm having this issue too. The After some investigation, the reason is because the |
I was having the mismatching hash issue as well. What solved it for me was setting the context property on webpack config and also referencing it in react-css-modules plugin option.
|
Facing still the same issue even though have followed the same above configuration, any idea how to fix it ? |
Ok was able to get around with the code provide by @jcw007 , but i must say the documentation does not explains the steps clearly, would like to make a pr for updating the documentation |
I'm trying to switch from React CSS Modules (which I have working fine) to this plugin. I'm using Gatsby which is using Webpack under the hood. Although I have the CSS module names being rendered to the rendered component's 'class' attribute correctly, the styles themselves are not being compiled.
My components look like this using Anonymous reference:
With the styles like this:
I've tried being more explicit, using Named references, but the problem is the same.
In my babelrc I've checked that Gatsby uses the same Webpack
context
and it uses the current directory like this plugin's defaultcontext
value. I have also setwebpackHotModuleReloading
totrue
To reiterate, things are working perfectly using React CSS Modules.
The text was updated successfully, but these errors were encountered: