-
Notifications
You must be signed in to change notification settings - Fork 2.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
react - using CSS Modules in a Nrwl NX workspace #1744
Comments
Hi @maku We don't currently support CSS modules but we can look at extending our builder for it. The workaround right now is to provide your own custom webpack to the web builder. Look in your
You need to switch Now, you need to provide the config function like this: https://gist.github.com/jaysoo/431828f47e5202d3e4afc6c34fdac2c0 This function modifies the webpack config by adding a rule to handle There will be more configuration beyond that, especially for production builds, postcss (if you use that), etc. |
Hi @jaysoo, thank you for answering. I would only use css modules when I don't have to fiddle around with the config (mainly I use Angular but I am curious about the React features in nx). But from my point of view it would make sense when nx is able to handle css modules... |
@maku Sounds good. I'm doing some refactoring on our babel support. After that is done this should be easy to add. |
@jaysoo I tried configuring the webpack configuration like mentioned above. Nx compiled it successfully but the class name doesn't seems to be shown in the render. Can I know the workaround to configure css modules in .scss? |
@sanjevirau See this demo here https://github.com/jaysoo/css-modules-example. Make sure you change Specifically, see https://github.com/jaysoo/css-modules-example/tree/master/apps/demo/src/app. |
Support for CSS modules have been added. It's the same as CRA so you need to name your files as |
How can I use scss modules in a react app in nx? |
Same here, but for less? |
@LucaFilitz @TheAifam5 You will need to provide your own webpack config extensions. Something like this:
|
https://hastebin.com/jugohuxupu.js This is a custom webpack config for .s[a/c]ss, .css and .module.s[a/c]ss I had help from @jaysoo ... psst :p |
This works well except when adding sass variables:
Which doesn't replace the variable with its value in the compiled css
(it does work with non module .scss files out of the box). |
@jaysoo thank you for css mosules support! |
@jaysoo this works well for apps, but it is failing in libs. |
Still failing in libs. Are there any work arounds? |
Same problem here, anyone found a solution? |
Is there a reason that SCSS modules are used by default if they're not supported? |
Why this is closed? |
Any update about lib support SCSS modules? |
Looking forward to an update as well |
Anything new? I'm on version 14.1.9 still no css modules support? |
I get the following error for a React component in a
I disabled noPropertyAccessFromIndexSignature. The error in IDE gone but the app didn't run. |
The problem still persists. The IDE config is gone, but the dev build still fails. |
If |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
I run version 8.4.12 of nx
I would like use css modules in a react app
In a recent react project, created with "create-react-app", I am able to use css modules.
e.g.
import
classes from './MyComponent.module.css';
and the usage:
<div className={classes.my-css-class}> </div>
How is this possible with nx?
The text was updated successfully, but these errors were encountered: