-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to plug this in? #24
Comments
Hey tnrich, This is a plugin designed to work with PostCSS, so make sure to read up on how it works before you jump into it. To make css-modules work with Webpack, I used css-loader and enabled the modules-property by appending the '?modules' section to css-loader. This configuration in my webpack.config.js works for me:
Keep in mind that the processing of chained loaders happens from right to left, so in this configuration, postcss-loader will be called first considering I also want to make use of postcss-cssnext before css-modules is called and the transformations happen. |
Does anybody have a working example of how to use this with css-modulesify? Everything I've tried so far has failed. Edit: it seems that this module is now included in the default set of plugins, so attempting to manually run it was causing a failure. The moral of the story is that if you're using css-modulesify, you don't need to do anything to enable values. \o/ |
I think it should be auto-enabled, but it doesn't work |
I think what is missing is the full webpack usage:
|
Has anyone had any luck using this with the css-modules/webpack-demo? I feel like this should be straightforward... :( |
@dominicwhittle best option would be to fork |
As someone who is so far only somewhat familiar with PostCSS and CSS modules, I interpreted the README on this module in that it was built into CSS modules. Glad I found this issue. Spent a good chunk of time debugging my build process on why examples from this module was not working. Any reason why there aren't any installation/usage example in the README? Other than no one made a PR yet. (I can do PR on webpack usage if you guys are open for it) |
It would be great to include basic getting started instructions in the README before diving into explicit usage. |
@apennell Sure. I'm working on new version right now. Would be great somebody help to describe cases according current tests. |
I'm working on new docs already :) (soon), but the plugin will get an overhaul update first as @TrySound already mentioned 😛 |
I'm getting an P.S. Importing those values in CSS works fine. The issue is only with importing in JS. |
If you use create-react-app, then you can plug this in by adding |
I feel like a total idiot. I have this code: postcss([
require("postcss-modules")({
root: this.options.root || file.info.absDir,
getJSON: (cssFileName, json) => {
...
},
generateScopedName: ...
})
]) So now I try to simply add postcss([
require("postcss-modules")({
root: this.options.root || file.info.absDir,
getJSON: (cssFileName, json) => {
...
},
generateScopedName: ...
}),
require('postcss-icss-values')
]) Still, it does absolutely nothing. Here is a chunk of my generated post-css:
Generated from a color.css:
Imported to my index.css:
In this example, I'm trying to replace |
Hey there,
It didn't seem like there was any mention of how to plug this code into css-modules. Do I need to do anything to get it to work?
Thanks
The text was updated successfully, but these errors were encountered: