-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Fix ICSS syntax in stylesheets #10511
Conversation
bump |
Bump. |
Is this merge still being reviewed? I'm hoping this issue gets resolved soon so I can remove the craco workaround from my project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are straightforward. Surely this can be merged?
Thanks @thabemmz! |
Thanks guys. |
When will this be released? |
Is this fix included in the 4.0.3 version? |
This does not appear to be fixed in 4.0.3. Could someone release the fix please? |
When will a new version be released? So this fix can be available |
Context
After upgrading Create React App to
v4
, the exported SASS variables did not work anymore in my project. This was a known issue for CRA@v4.Cause of the issue
In CRA@v4,
css-loader
was upgraded from v3 to v4. Incss-loader
v4 there was a bug that did not handle ICSS (the syntax within CSS modules used to:import
and:export
) imports properly. This has been resolved by adding thecompileType
property in v4.2.0.In the README of
css-loader
, there is a whole section about how to configure your setup to support ICSS properly when used together with CSS modules (see here).What has been done?
compileType
to all style rules in Webpack config of CRA. Useicss
for non-modules andmodule
for all modulesHow to test?
I tested this in my own project, but in the Create-React-App project, I verified this works by doing the following:
yarn start
packages/cra-template/template/src
, renameApp.css
toApp.module.css
, in the class-names replace all kebab-cased classnames to camelcase (for testing purposes)App.js
, change the import toimport Styles from './App.module.css';
and replace all classnames withStyles.App
-like variantfoo.css
with the following content::export { black: #000000; }
App.js
, add the following import:import vars from './foo.css'
App.js
, change the<p>
on line 10 to<p style={{ color: vars.black }}>
:export
syntax is working properly.(cd packages/cra-template && yarn add node-sass)
and runyarn start
again.css
files withinpackages/cra-template/template/src
to.scss
:export
syntax is working properly, even in SCSS 🎉