T
T
The_KEK2022-02-22 14:33:57
css
The_KEK, 2022-02-22 14:33:57

Why doesn't the path to SCSS images appear?

In SCSS, when filling in the path to the image, hints do not appear, although the image is displayed

6214c8d66d619957807432.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2022-02-22
@The_KEK

This is the path from the output css file, not from the sass file in which it is written.
Feel the difference?
sass still doesn't have a built-in file path resolver, unlike other preprocessors.
That is, the paths to the files are not processed in any way, and are sent to the output as it is.
This is problem.
For example, you have a structure like this:

dist/
  css/
    style.css
  images/
    image.png
src/
  images/
    image.png
  sass/
    blocks/
      logo.scss
    styles.scss

as long as you write directly in styles.scss, everything is fine. The path is the same in both your undercodes and the build. Storm gleefully gives out clues. As soon as you decide to write in a separate blocks/logo.scss file, the path to the image in the sources becomes different, but in the build it remains the same. Storm cannot issue a hint. In other preprocessors, you can write the source path . They will convert the output path to the correct one. Not in sass. If you are using webpack as a faucet, then there is a resolve-url-loader for it, which somehow fixes this flaw. Another solution is to use paths from the root. Here the storm can tell. You only need to mark the dist folder as Resource root.
.logo { background: url(../images/image.png); }
.logo { background: url(../../images/image.png); }
.logo { background: url(/images/image.png); }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question