Closed haldunanil closed 6 years ago
Am I doing something wrong or is this a bug?
Nope. That's just how Sass works (https://github.com/sass/node-sass/issues/2218#issuecomment-358578777).
Depending on how you've configured webpack (e.g. with the resolve-url-loader) webpack can resolve relative URLs in your Sass code. But node-sass
can't do that out of the box, this is the expected behavior and has nothing to do with node-sass-magic-importer
.
You have to use paths relative to the output, not the source file. Or you can compile your CSS via webpack and the resolve-url-loader
.
Hi!
I have a build process that works as follows:
.scss
file that imports a globalmain.scss
in its first line to get access to project-level variables.build.scss
file that includes a single line@import "../../components/**/*.scss";
to grab all the.scss
files throughout the project.npm run build
, my package runs the following script:node-sass ./src/styles/scss/build.scss ./src/styles/alfheim-react.css --importer node_modules/node-sass-magic-importer/dist/cli.js
to join all those disparate.scss
files into a single one.Relative imports at the top of the file work perfectly fine, but when they're inserted into the CSS, they no longer work. For instance, I have the following lines:
However, when I run the build process the
background-image
url remains the same relative path (i.e../right-bracket.svg
), which results in the.scss
file no longer being able to find the svg. Am I doing something wrong or is this a bug?