Using SASS_PATH in .env triggers warnings in console
See original GitHub issueDocumentation for using SASS at https://create-react-app.dev/docs/adding-a-sass-stylesheet mentions that I can create .env
file with SASS_PATH
option so when importing files in SCSS I don’t need to use relative paths and use just for example @import 'vars'
.
However, when I use SASS_PATH
I get a lot of warning messages in when starting the app with npm run start
.
WARNING in ./src/components/Content/Content.module.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[8].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[8].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[1].oneOf[8].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[8].use[4]!./src/components/Content/Content.module.scss)
Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.
As best effort we try to convert all invalid values to absolute paths and converting globs into context dependencies, but this is deprecated behavior.
Loaders: Pass absolute paths to this.addDependency (existing files), this.addMissingDependency (not existing files), and this.addContextDependency (directories).
Plugins: Pass absolute paths to fileDependencies (existing files), missingDependencies (not existing files), and contextDependencies (directories).
Globs: They are not supported. Pass absolute path to the directory as context dependencies.
The following invalid values have been reported:
* "src/styles/_vars.import"
* "src/styles/_vars.import.css"
* "src/styles/_vars.import.sass"
* and more ...
Environment
Environment Info:
current version of create-react-app: 5.0.1
running from /Users/martinsikora/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.5
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Browsers:
Chrome: 104.0.5112.79
Edge: Not Found
Firefox: Not Found
Safari: 15.6
npmPackages:
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
react-scripts: ^5.0.1 => 5.0.1
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- create
.env. file with
SASS_PATH` variable as described in https://create-react-app.dev/docs/adding-a-sass-stylesheet.
Expected behavior
Should not print any warnings.
Actual behavior
Prints a lot of warnings into console.
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5
Top Results From Across the Web
console.warn() - Web APIs | MDN
The console.warn() method outputs a warning message to the Web console.
Read more >How to clear/disable minor and warnings console log error?
I simply want to prevent warning messages to be printed in the console log automatically using JavaScript. I've already tried the console.clear() but...
Read more >Catch warnings in Jest tests | Ben Ilegbodu
It displays warnings in the console (i.e. console. warn ) when the type checking fails for a component. Because these types of warnings...
Read more >Trigger Warnings | Centre for Teaching Excellence
A trigger warning is a statement made prior to sharing potentially disturbing content. That content might include graphic references to topics such as ......
Read more >Why trigger warnings are really so controversial, explained - Vox
She joined Vox in 2014. Hofstra University didn't actually put a sign with a trigger warning outside the auditorium where the first debate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Add
SASS_PATH=src
to your.env
file assuming your SASS files code is insrc
folder. Add the same variable to any other local environment files you might use like.env.development
.In your
.scss
files, import using the absolute syntax like@import "src/scss/variables";
instead of@import "scss/variables";
@martinsik @web-bert See solution in https://github.com/facebook/create-react-app/issues/12329#issuecomment-1303783916