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

Docs for importing Sass partials shows broken use of @use #12027

Open
alexmkio opened this issue Feb 7, 2022 · 1 comment
Open

Docs for importing Sass partials shows broken use of @use #12027

alexmkio opened this issue Feb 7, 2022 · 1 comment

Comments

@alexmkio
Copy link

alexmkio commented Feb 7, 2022

Describe the bug

When importing Sass partials one must use @import and not @use as the docs suggest.

Did you try recovering your dependencies?

yes. npm version = 8.4.1

Which terms did you search for in User Guide?

'use import sass partial'

Environment

current version of create-react-app: 5.0.0
running from /Users/alexkio/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

System:
OS: macOS 12.2
CPU: (10) x64 Apple M1 Pro
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 8.4.1 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Chrome: 98.0.4758.80
Edge: Not Found
Firefox: Not Found
Safari: 15.3
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. npx create-react-app my-app
  2. cd my-app
  3. npm start
  4. npm install sass
  5. rename App.css to App.scss
  6. create _variables.scss with $grey-dark: #282c34;
  7. in App.scss @use './_variables.scss'; and change background-color: #282c34; to background-color: $grey-dark;

Expected behavior

npm start should load without errors

Actual behavior

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined variable.

19 │ background-color: $grey-dark;

Reproducible demo

Project that fails to build using npm start and @use as suggested in the docs

Project that builds using npm start and @import

@alexmkio
Copy link
Author

alexmkio commented Feb 7, 2022

Found a solution for using @use based off Sass documentation.

@use './variables'
background-color: variables.$grey-dark;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant