-
Notifications
You must be signed in to change notification settings - Fork 54
Add better examples #23
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
Comments
https://github.com/tone-studio/ui-patterns Here's an example how I am using it to generate standalone modules. I'm pretty sure there's an easier way to do this. What I'm doing:
This is the order, per definition of this plugin "plugins": [
["css-modules-transform", {
"generateScopedName": "./scripts/generate-scoped-name.js",
"preprocessCss": "./scripts/preprocess-css.js",
"extensions": [".css",".scss"],
"extractCss": {
"dir": "./lib/",
"relativeRoot": "./src/",
"filename": "[path]"
}
}]
]
} All files are then generated in the lib folder. (I adjusted the filename: See #24) Since this plugin does not resolve dependencies I had to manually add After the above steps are done I run I want to try to work without any extra build tool and your plugin is really helpful so far but I'm not sure if I'm over-engineering the transpile step. |
As I wrote in comment for #24 there is a bug in What do you mean that this plugin does not resolve dependencies? Can you write a simple example please? |
Thx for the quick response. I guess this is only an issue because of the structure I chose for that project. It works well as it is. I was just wondering if there is a better way to make sure css files are fully resolved (include all dependencies) while the js files are simply babelified |
|
By dependencies you mean images, etc? |
I mean required files:
Basically what |
Ok I think that I understand now. Basically you want something like combined.css but for directory / entrypoint. So for example for your Maybe we can do something like that but using some special option for
|
But it is tricky because babel does not follow import/require statements, it just loads all files and processes them. Webpack on the other hand follows import/require statements so it is aware about context. |
If I use
|
Have you tried to use css-modules/css-modules-require-hook#58 (comment) There is also mention about sync mode of |
Because you need to resolve imports before css AST is processed. |
I've played around with various combinations. The current solution seems to work well. The only downside is having to import css files. |
I think we can close this issue. I don't see any simple solution for this problem and as I wrote, babel don't know about context because it does not follow imports/requires so we can't construct tree of css files. |
👍 |
IMHO it is very hard to understand how this works.
I think some real world examples with different combinations would help.
I looked into the tests but could not find any tests which combine certain properties (e.g.
preprocessCss
+generateScopedName
)As-is, I cannot use this plugin due to fear of misconfiguration.
Happy to contribute if I figure out how it works.
The text was updated successfully, but these errors were encountered: