简体   繁体   中英

Resolving asset location issues using SASS in PHPStorm

I have a project where the basic asset folder structure looks like this:

/css
/css/sass
/js
/images

When I compile the SASS files, it places them into the css folder above. I do it this way to try and keep my directory structure logical and simple.

I'm using relative paths in my SASS files to link to images:

background: url(../images/foobar.png);

However, since the path is relative from the CSS directory, PHPStorm flags it as an error.

Is there any way to configure PHPStorm to be able to recognise assets from a destination path, and not just directly from the SASS file?

Replace:

background: url(../images/foobar.png);

With:

background: image-url('foobar.png');

To use the compass image-url() function. The inspection errors from PHPStorm will then disappear, and compass will automatically generate the correct path based on the image resource root.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM