WebStorm SCSS resolving limited to current file scope ?

It seems that contrary to the Javascript resolver, for SCSS the definitions of mixins, variables and files are not automatically found as soon as the source file is part of the whold project, but the scope seems to be limited to each file separately ?

I have Compass support configured properly with a config.rb file, in WebStorm settings.

If I open a partials file, unless there is an explicit import at the top of the file, variables or mixins coming from other partials included in the scss project fail to be found.

Also, the paths for the imports need to be absolute or relative, and do not take into account any of the add_import_path directives specified in the config.rb, even though the compass file watcher compiles the scss project without errors and finds the references.

Is that normal ?

14 comments
Comment actions Permalink

Hello, anyone ?

0
Comment actions Permalink

Hello!

can't recreate - additional paths configured with 'add_import_path' work for me. Can you attach a sample project that shows up the issue?

Mixins, etc that are not imported explicitly also work for me - they are suggested by completion, navigation works, etc. The only problem I have is that they are shown underwaved, with the following warning being displayed: 'element 'foo' is resolved only by name without using an explicit import''. If you don't like to get warnings on implicitly imported elements, you can turn this inspection off

0
Comment actions Permalink

Hello

okay thanks I see that it was not an actual error but an inspection warning, thanks for the precision.

I deactivated this inspection warning and am trying the following:

There are three files :

wwwroot\test1\scss\app.scss with contents :

@import "lib/foo";


wwwroot\test1\config.rb with contents :

http_path = "/"
project_path = "c:\\wwwroot\\test1"
css_path = "c:\\wwwroot\\css"
sass_path = "c:\\wwwroot\\test1\\scss"
add_import_path "c:\\wwwroot\\bar"


and  wwwroot\bar\lib\_foo.scss which contains

.dummy {
     color:red;
}


Now what happens is that, Compass does compile app.scss properly.
But WebStorm does show a warning in file app.scss saying that it "Cannot resolve import into sass/scss file".

If I put a forward slash here :

@import "/lib/foo";


Then the warning dissapears in WebStorm and I am able to control-click on the file reference, however Compass now says it does not find the requested file.

Did I make a mistake somewhere ?

0
Comment actions Permalink

Just tried the similar setup in WebStorm 7.0.3 - works fine for me
Are other imports resolved? '@import "compass"', for example?
Also, am I right thinking that c:\\wwwroot\\test1 is your WebStorm project folder, so that the additional scss files are located poutside of the project folder? Anyway, both setups (within a project and in some external folder) work for me - no warnings, ctrl+click works as expected

0
Comment actions Permalink

Hello and thanks for your answer.

no, @import "compass" is also not resolved.

and yes, stuff in lib folder is supposed to be outside of project folder specified in config.rb, because it's some unmodified lib scss files, but they are still inside the WebStorm project folder (wwwroot).

would it be maybe possible to have a zip of your test which works, to see exactly the values and the paths, so I can find out what is different on my side ?

0
Comment actions Permalink

as compass import is not resolved as well, the issue seems to be caused by compass settings. What does the path to compass executable in Settings/Compass Support look like? It should be smth like 'C:\Ruby193\lib\ruby\gems\1.9.1\gems\compass-0.12.2\bin\compass' (and NOT 'C:\Ruby193\bin\compass' suggested by default)

0
Comment actions Permalink

Well the path in the settings is C:\Program Files (x86)\Ruby200\bin\compass

and as it works for compiling, I could not know that I should have changed it ...

Using the path C:\Program Files (x86)\Ruby200\lib\ruby\gems\2.0.0\gems\compass-0.12.2\bin\compass

Everything including @import compass is now resolved. Maybe it should be added as a hint or note in WebStorm Compass config dialog or something ?

However now, the compass compile file watcher is broken....

What path should I use for this one please ?

0
Comment actions Permalink

The path in file watcher should be the default one - C:\Program Files (x86)\Ruby200\bin\compass.
Yes, they are different:(

http://youtrack.jetbrains.com/issue/WEB-9139 (wrong executable path is set by default on Windows) is fixed in WebStorm8, so paths will be set correctly in the future version, and there will be no such confusion

0
Comment actions Permalink

Well if I use the path you provided, I get the error "%1 is not a win32 application"

and if I delete the watcher and let WS create it again itself (from the suggestion "there is a file watcher available ..." then I get the path

C:\Program Files (x86)\Ruby200\lib\ruby\gems\2.0.0\gems\compass-0.12.2\bin\compass.bat

which does not work because there is no compass.bat there...

What seems to work is to manually change the path to

C:\Program Files (x86)\Ruby200\bin\compass.bat

and the arguments to

compile E:/WebClient/app    (which is the root of my project in config.rb)

, removing the $FileName variable thing which apparently makes it compile only that file?

0
Comment actions Permalink

please try 'C:\Program Files (x86)\Ruby200\bin\compass.bat'

0
Comment actions Permalink

Yep that worked indeed, I just updated my last post

0
Comment actions Permalink

I just have a little warning when the watcher is executed :

"C:/Program Files (x86)/Ruby200/bin/compass.bat" compile E:/WebClient/app
ArgumentError on line ["500"] of C: different prefix: "C:/" and "e:/webclient/app/css"


What does it even mean ??

0
Comment actions Permalink

This is a compass problem - seems it occurs ifyour project is located on a different drive than C:\ where Ruby is installed. See https://github.com/gregbell/active_admin/issues/270

0
Comment actions Permalink

ok thanks, not a big issue, it compiles okay

plus for some rason a simple "compass watch" command outside of webstorm does not produce such a warning..

Thanks for your help Elena, I am glad to finally have my webstorm scss compilation and imports working fine !

0

Please sign in to leave a comment.