node_modules resolve not working with @import for SCSS
See original GitHub issueI’m running into this error msg when I’m trying to @import
a .scss file from my node_modules
folder via this method:
@import "react-input-range/src/scss/index.scss";
Results in this error:
[!] (postcss plugin) Error: File to import not found or unreadable: react-input-range/src/scss/index.scss.
However, if I include the entire relative path to the .scss, that’ll work:
@import "../../../../../../node_modules/react-input-range/src/scss/index.scss";
and this works as well
@import "react-input-range/lib/css/index.css";
I need to import the .scss to override the SASS variables, so can’t make use of of the .css file. I can’t seem to figure out the cause and need some assistance with my issue, thanks!
So to reiterate:
Component.scss
// Works
@import "react-input-range/lib/css/index.css";
@import "../../../../../../node_modules/react-input-range/src/scss/index.scss";
// Does not work
@import "react-input-range/src/scss/index.scss";
rollup.config.js
import easyImport from "postcss-easy-import";
import postcssFlexbugsFixes from 'postcss-flexbugs-fixes';
import autoprefixer from "autoprefixer";
postcss({
sourceMap: true,
minimize: true,
modules: true,
namedExports: true,
plugins: [
easyImport,
postcssFlexbugsFixes,
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
extract: path.resolve("./dist/style.css"),
}),
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
node_modules resolve not working with @import for SCSS #345
I'm running into this error msg when I'm trying to @import a .scss file from my node_modules folder via this method: @import "react-input-range/ ......
Read more >SCSS cannot resolve imports (node_modules) in IDE - YouTrack
SCSS cannot resolve imports (node_modules) in IDE - but actually works on ng serve. Relates to 2 Duplicates 1. Relates to 2 issues...
Read more >Webpack can't resolve @import of scss/css - Stack Overflow
Before I was trying to import another file into my stylesheet, I got my *.css file back. Everything works, the only problem starts,...
Read more >Import a SCSS files from Node Modules - Laracasts
Hi, I'm trying to load some styles from the node_modules folder. But it's a real pain to do so. Usually, when I'm not...
Read more >Sass: @import
The @import rule has a number of serious issues: ... users to provide load paths: paths on the filesystem that Sass will look...
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
Does
@import "react-input-range/src/scss/index.scss";
work in regular node-sass? From what I can tell it’s importing a file relative tocwd
instead of the one innode_modules
.However I think you can use includePaths option to make this work:
btw in
v1.3.0
you can prepend it with~
to import fromnode_modules
, see: https://github.com/egoist/rollup-plugin-postcss#imports