Visual studio suppress error on undefined SASS variable - visual-studio

I'm trying to suppress a specific error that is related to a SASS file in Visual Studio. I'll mention that everything works great, the CSS file is generated exactly as the SASS files should generate it, and even with this error on VS, so I think maybe it's a bug on VS.
Basically what I'm doing is that I have 2 SASS files that I declare some variables in them as settings for another SASS file that contains some mixins that work according to the settings file that provided in the context.
For exmaple, these are the 2 files for the settings:
_settings-ltr.scss
$bi-app-left: left;
$bi-app-right: right;
_settings-rtl.scss
$bi-app-left: right;
$bi-app-right: left;
And this is the file that uses those settings:
_mixins.scss
#mixin padding-left($distance) {
padding-#{$bi-app-left}: $distance;
}
#mixin padding-right($distance) {
padding-#{$bi-app-right}: $distance;
}
Now, basically the error says that the variable "$bi-app-left" is undefined (and "$bi-app-right" as well), and I'm really not defining these variables in the "_mixins.scss" file, I pass them to the context in some other SASS file, like this:
site.scss
#import '_settings-ltr.scss';
#import '_mixins.scss';
And it works great, except that error from VS:
My Question
How can I disable this error specifically, without disabling other SASS file errors?

This is because of how the VS SCSS editor resolves variables. It does so from the perspective of the file being edited; because the SCSS editor instance for _mixins.scss does not know how the imports are resolved in site.scss, it doesn't have a way to resolve this reference. If _mixins.scss had an #import chain up to the _settings-ltr.scss (or -rtl), then it would be able to resolve the variable and the error wouldn't be shown.
Similar feedback has been raised here as well. It would be worth opening a new feedback item to better describe the scenario (and also what you're using to compile SCSS, e.g. if you're using WebPack) so the team can prioritize this as a design change. It won't get addressed right away, but we do take the number of feedback items into account for prioritizing the backlog. (And I'd love to have more ammunition to make this feature a priority...)
Currently, there isn't a way in VS to disable a specific SCSS error. This could be another feature request, but it would be a low priority to implement.

I have activated intellisense for files declared elsewhere by referencing the main file (i'll name it mainfile at my example) that imports all the other using /// <reference path="./../mainfile" />.
The code should change depending on the nesting of the mainfile (replace with the name of your own starting file that imports everything else).
Also the difference between the scss file you are adding it. For instance for two folders deep ./.. for three ../.. and so on.
Another example. I usually name my starting file main and all scss files are two - three folder deep.
../../main
./../main
Sadly i did not find a dynamic way to reference the path based on unknown members of files. Also that line has to be added to every single file.
The solution above offers intellisense which sorts the error and you can see the values on hover, go to definition etc as well.

Related

understrap child theme - scss changes are not appied/visible

I am having problems with "creating" an Understrap Child theme.
I am using Visual Studio Code and I have a plug in Live Sass Compiler.
The problem I am facing is that when I change/create the variables in _theme.scss and save it, no changes are shown on the website.
My child theme structure:
-understrap-child
*functions.php
*index.php
*style.css
-sass
-theme
*_theme.scss
*_theme_variables.scss
My understanding is that a scss file with an underline is a partial scss file, and as such is not a stand alone file. If I save a regular scss file, without an underline it creates a regular file.
So my questions comes down to, do I need another .scss / .css file where the values from _theme.scss would be applied?
If I can provide any additional information, please let me know.
Edit1:
I think the problem is that I am not importing the underscore/partial files to any other non-underscore files. Since underscore files are partials, I am quite sure they need to be imported into non-underscore / specific files?
VScode - Live Sass Compile console
--------------------
Watching...
--------------------
Change Detected...
_theme_variables.scss
--------------------
Compiling Sass/Scss Files:
--------------------
Watching...
--------------------
Change Detected...
_theme.scss
--------------------
Compiling Sass/Scss Files:
Edit2:
I have downloaded an understrap-child theme from github, but the problem persists.
Edit3:
I have not resolved this problem. I am now using another theme without issue.
write variables colors in
_variable_theme.scss
then import this file in :
_theme.scss ==>
#import '_variable_theme.scss'
for example:
//_variables_theme.scss
$primary-color: #302AE6;
$secondary-color: #536390;
$font-color: #424242;
$bg-color: #fff;
$heading-color: #292922;
// _theme.scss
#import '_variable_theme.scss'
body{background:$primary-color}
, try it.
I faced a similar issue. If you're using an understrap-child theme, the variable overrides can be made on src/sass/theme/_child_theme_variables.scss; I was able to successfully modify $primary value here.
The earlier mistake was expecting theme changes on modifying src/sass/assets/understrap/theme/_theme_variables.scss !!

WebStorm doesn't compile main SCSS on partial update

I'm building in WebStorm.
I have a main.scss witch references several partial files (names prefixed with _) via #use. I have a file watcher set up and everything works fine when I'm working in the main.scss - I make changes, they get compiled and are reflected in my build.
When I make change in a partial though they don't seem to trigger the file watcher. In order for the changes to show in the build I have to jump back to main.scss and make some small change that triggers the watcher and everything gets compiled. This is a bit of a pain to keep having to do but I've tried messing around with the watcher settings and have had no luck.
Can anyone suggest a way to trigger the file watcher when partial SCSS files are updated?
Thanks
Not a full answer as WebStorm just doesn't seem to want to play ball but in the end I set up webpack and am using the sass-loader which seems to work as desired and actually makes more sense as I'll usually be running webpack anyway.

.scss not updating style in MVC project

I've searched this question but cant fnd the right question I'm asking about.
I have an MVC project and there's some auto-generated css files that I dont use. I have a scss folder with a file a .scss file called _main-style.scss.
I have a another file that references these sheets, and I use
#import 'sections/main-style';
I'm following the same naming convention as the others.
I even right clicked and did compile. When I run on the browser, it still doesnt update. I inspect the element and the classes dont exist. It's like its not getting them at all.
Can someone help?
Thanks in advance.
From your description, seems like you know about scss and how to compile it to css.
I have an MVC project and there's some auto-generated css files that I dont use.
BUT, What do you mean by this?
Normally if you compile scss to css, and if that css is already linked with your document, It should update automatically
Turns out it needed a hard refresh

Helper functions of SCSS and Compass in Visual Studio 2013 Update 4 / Web Essentials?

I recently migrated to Visual Studio 2013 Update 4 and installed Web Essentials 2013 for Update 4. I downloaded the compass files and tried to do my very first sass (scss) files.
Two issues I could solve already by myself (see "solved" below), still two more to go :-(
OPEN: Detailed error message?
I discovered was that there seem to be two different kind of errors. One kind of error Visual Studio / Web Essential are handled with a wavy underline or telling the reason on the result window on the right, which is totally fine, but I am having trouble with "other kinds of errors", where my CSS simply doesn't get updated and it is not telling me why.
In the Output Window I can see:
SCSS: myfile.scss compilation failed: The service failed to respond to this request
Possible cause: Syntax Error!
But no further details. Is there any kind of log file?
OPEN: #mixing for image-width not working
Calling the method image-width or image-height (as described here: http://compass-style.org/reference/compass/helpers/image-dimensions/ )
always ends up in an "Syntax Error!" error as shown in the open issue above.
The code I'm using is pretty simple (file in the same location and exists):
width: image-width("MyImage.jpg");
SOLVED: Import Issue
I could solve the problem why the following statement wasn't working:
#import "compass";
Instead, I have to specify a specific file and not a folder, like so:
#import "compass/reset/_utilities.scss";
Reason: Regarding to the sass-lang documentation, the decleration is not for folders, it is actually for "Partials" (http://sass-lang.com/guide#topic-4) and underscore sass files are treated as such. In my project I had the compass folder included, but I was missing the _compass.scss file (this is what #import "compass" was looking for).
SOLVED: Calling basic Compass funtionallity
I could solve: Basic Sass-functionality works, but by calling the compass mixin such as global-reset in, the renderd code looks like this
...
elements-of-type(html5-block) { display: block; }
...
Solution: In the Visual Studio Options, Navigate to WebEssentials > SASS > Use Ruby Runtime and set the value to "True"

Save SASS to same as origin files

I am using sass with prepros compiler and sublime editor. I need to have each scss file complied with the same file name.
For example:
I currently have-
header.scss
content-top.scss
footer.scss
and they are all compiles into style.css to create one full style sheet.
I wish to have a style folder with
header.css
content-top.css
footer.css
which will be done automatically when saving and compiling like I normally do.
How can I accomplish this?
Thank you
Check this link out.
It states that you can adjust your project structure (in your case CSS folders) in project settings.
If I remember correctly you may have to buy it so that you can compile more than 4 or 5 Sass files, but I may be wrong.
Also check that you aren't "only" importing sass partials because of this:
Any Sass and Scss file (i.e. including partials) imported by another
file are not shown in the files list but they are still watched by Prepros.
The parent file is re-compiled whenever any of the imported files are changed.

Resources