Fix ICSS syntax in stylesheets#10511
Merged
ianschmitz merged 1 commit intofacebook:masterfrom Apr 12, 2021
Merged
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. |
richardoptibrium
left a comment
There was a problem hiding this comment.
The changes are straightforward. Surely this can be merged?
This was
linked to
issues
Apr 12, 2021
Contributor
|
Thanks @thabemmz! |
|
Thanks guys. |
|
When will this be released? |
|
Is this fix included in the 4.0.3 version? |
wombleton
pushed a commit
to AurorNZ/create-react-app
that referenced
this pull request
Jun 1, 2021
|
This does not appear to be fixed in 4.0.3. Could someone release the fix please? |
sumanthratna
pushed a commit
to sumanthratna/create-react-app
that referenced
this pull request
Aug 4, 2021
|
When will a new version be released? So this fix can be available |
abhiisheek
pushed a commit
to abhiisheek/create-react-app
that referenced
this pull request
May 24, 2023
This was referenced Oct 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-loaderwas upgraded from v3 to v4. Incss-loaderv4 there was a bug that did not handle ICSS (the syntax within CSS modules used to:importand:export) imports properly. This has been resolved by adding thecompileTypeproperty 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?
compileTypeto all style rules in Webpack config of CRA. Useicssfor non-modules andmodulefor 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 startpackages/cra-template/template/src, renameApp.csstoApp.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.csswith 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 }}>:exportsyntax is working properly.(cd packages/cra-template && yarn add node-sass)and runyarn startagain.cssfiles withinpackages/cra-template/template/srcto.scss:exportsyntax is working properly, even in SCSS 🎉