Skip to content
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

ICSS export not working in CRA 4 #10155

Closed
justsolarry opened this issue Nov 26, 2020 · 4 comments · Fixed by #10511
Closed

ICSS export not working in CRA 4 #10155

justsolarry opened this issue Nov 26, 2020 · 4 comments · Fixed by #10511

Comments

@justsolarry
Copy link

Describe the bug

Exporting keys like this used to work in CRA 3 (react-scripts : 3.4.4) but when we upgraded to CRA 4 (react-scripts : 4.0.0) it stopped working.
image
After exporting, you can use it like this:
image

Did you try recovering your dependencies?

1.22.4

Which terms did you search for in User Guide?

export
ICSS

Environment

Environment Info:

current version of create-react-app: 3.4.1
running from /Users/you-haurliu/.config/yarn/global/node_modules/create-react-app

System:
OS: macOS 10.15.7
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 12.16.1 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 87.0.4280.67
Firefox: 82.0
Safari: 14.0
npmPackages:
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-scripts: 3.4.4 => 3.4.4
npmGlobalPackages:
create-react-app: 1.5.2

Steps to reproduce

  1. Use CRA and create a project
  2. install node-sass as a dependency to allow for scss files
  3. Create a new file called colors.scssin the src folder
  4. Add this block of code inside colors.scss
:export {
  primary: red;
}
  1. import this file in app.js with import colors from './colors.scss'
  2. Apply the style to any p tag
  3. For example
<p style={{color: colors.primary}}>
      This should be red
</p>
  1. The text should be red

But if you update react-scripts to 4.0.0 and delete the node modules and yarn lock. Then yarn and start up the server, the text is white and the colors object is empty.

Expected behavior

colors object should contain primary

Actual behavior

colors object is empty

Reproducible demo

Instructions are included in the link
https://github.com/justsolarry/test-cra

@ghoullier
Copy link

I confirmed the problem on react-scripts@4.0.0 and react-scripts@4.0.1

@ghoullier
Copy link

@justsolarry I've create a repository the share my investigations about this problem

TD;LR; the problem seems to come from a regression introduce by css-loader@4.

I will continue my research on this problem, and share here my progression.

@ghoullier
Copy link

According to @alexander-akait response webpack-contrib/css-loader#1262 (comment)
There is no current solutions to fix the problem without ejecting your app :(

I will propose soon a PR to support /\.icss\.(scss|sass)$/ pattern natively in create-react-app.

@ghoullier
Copy link

There is already a PR opened by @thabemmz to fix this issue.

@ianschmitz ianschmitz linked a pull request Apr 12, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants