Sublime Forum

Strange Behaviour When I Save CSS File

#1

I have had no problem like this till this afternoon.
On saving a couple of changes to the styling file via CTRL + ALT + S, I get a lower-half screen present the following info on my “error”:

error /home/sandbar/Desktop/Speediwash Webfiles/css/speediwash.css (Line 53: Inconsistent indentation: " \t" was used for indentation, but the rest of the document was indented using 1 tab.)
[Finished in 0.2s with exit code 1]
[cmd: [‘sass’, ‘–update’, ‘/home/sandbar/Desktop/Speediwash Webfiles/css/speediwash.css:/home/sandbar/Desktop/Speediwash Webfiles/css/…/css/speediwash.css’]]
[dir: /home/sandbar/Desktop/Speediwash Webfiles/css]
[path: /home/sandbar/Desktop/nodeapp/node_modules/.bin:/home/sandbar/Desktop/nodeapp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-15-oracle/bin:/usr/lib/jvm/java-15-oracle/db/bin:/home/sandbar/bin:/usr/java/oracle/jdk-15.0.1/bin:/usr/lib/jvm/java-15-oracle/bin:/usr/lib/jvm/java-15-oracle/db/bin:/home/sandbar/bin:/usr/java/oracle/jdk-15.0.1/bin]

There have been no recent changes to Sublime Text like new packages installed.
And since the last packages were installed (packages to facilitate SASS compilation to CSS, etc) I have had not had any such error until now.

The error itself is one of those pedantic things about tabs and whitespace.
Yet when I corrected the line in question, it simply finds some other whitespace based error.

What is going awry here ?

0 Likes

#2

The error is emitted by the Sass compiler and ST is just forwarding it to you.

0 Likes

#3

I removed all SASS or SCSS related packages from Sublime Text.
But issue was still there.

I got a message saying that my SASS compiler package on Ubuntu (sass) is deprecated and I should move to something else, e.g. sassc:
https://packages.ubuntu.com/focal/sass

Strange that it suddenly failed this week.
But since the CTRL + S and CTRL + ALT + S, i.e the Save and Save All commands, trigger the build process for updating any SASS to CSS, I get some stupid error.

It’s hard to find a good procedure online for creating a build process on Sublime Text for SASS and SCSS.

0 Likes

#4

I don’t think this is a built-in default behavior. I.e.,

is probably not true.

0 Likes

#5

Literally you got

Inconsistent indentation: " \t" was used for indentation, but the rest of the document was indented using 1 tab

for every Sass file when saving it?


Otherwise, just fix what it says…

0 Likes

#6

The ‘errors’ about spaces and tab indentation were clearly nonsense - and well you know it. These sort of ‘errors’ are often listed after something else is wrong, in this case my Ubuntu sass package was deprecated and advised installing sassc instead.
Instead I have installed Dart2JS SASS linked to the npm SASS package - I believe that this is what is now run when the sass command is executed.

I am still experiencing problems with the build script and its annoying side-effects, like the console popping up on the lower half of the screen and noisy ‘pop’ sounds whenever I Save or Save All pages.

I don’t think ST has properly adapted itself for use with any SASS or SCSS compiler. Maybe ST front end coders use Gulp or Grunt to perform this build and don’t seriously test the Sublime Text plugins for the SCSS -> CSS conversion.

Let’s hope that ST4 does better here - even if it just openly acknowledges that it abjures SASS support, that would be a good step forward.
ST4 could also do with changing the Package Control options to allow multiple packages to be removed at a time - right now if you have 8 packages to remove, you have to remove them one-by-one. I am not saying take away the option of one-by-one package removal. I’m saying enable a new multiple package removal option.

0 Likes

#7

Let’s hope that ST4 does better here - even if it just openly acknowledges that it abjures SASS support, that would be a good step forward.

This is all plugin functionality, I don’t really see what ST4 could possibly change to affect this. SASS isn’t supported by default afaik. I’ve used scss for years in ST3 with no issues only using a syntax highlighting package.

ST4 could also do with changing the Package Control options to allow multiple packages to be removed at a time - right now if you have 8 packages to remove, you have to remove them one-by-one. I am not saying take away the option of one-by-one package removal. I’m saying enable a new multiple package removal option.

Note that package control is somewhat separate from Sublime HQ and not directly related to ST4. I suggest posting such a feature request on the package control issue tracker.

1 Like

#8

@bschaaf:

I think you would do better to detail which scss plugins you use and what else you did to configure things so that changes to the .scss file are added to the related .css file on save.

I had been using a plugin called SublimeOnSaveBuild to do this.
After installing that plugin, I went to Tools > Build System > New Build System …
This opened a new config file called untitled.sublime-build.
I replaced the default code generated for this file with

{
“cmd”: [“sass”, “–update”, “$file:${file_path}/…/css/${file_base_name}.css”]
}

Then I saved that to build file that I named as scss.sublime-build.

After this I went back to Tools > Build System

and the build menu should now have an entry for scss (the build file just created).
Select scss as the build system and it is check marked.
From now on all Save operations done to a .scss file will provoke an execution of the sass program on that myproj.scss file which will then redirect the myproj.css output to a folder called css in the same project.

That is what I was doing for the past few weeks until it all became unstable a couple of days ago.

Question is, what have YOU been doing ?

0 Likes

#9

Your build system has no restriction on selector. That mean you claim it can be used on any file, such as a .js file.

What if you use

{
    "cmd": ["sass", "--update", "$file:${file_path}/…/css/${file_base_name}.css"],
    "selector": "source.sass, source.scss",
}

I suspect that you have a CSS file (/home/sandbar/Desktop/Speediwash Webfiles/css/speediwash.css) opened in a secret tab and you don’t know you were trying to compile it with sass with your “Save all” habit.

error /home/sandbar/Desktop/Speediwash Webfiles/css/speediwash.css (Line 53: Inconsistent indentation: " \t" was used for indentation, but the rest of the document was indented using 1 tab.)
[Finished in 0.2s with exit code 1]
[cmd: [‘sass’, ‘–update’, ‘/home/sandbar/Desktop/Speediwash Webfiles/css/speediwash.css:/home/sandbar/Desktop/Speediwash Webfiles/css/…/css/speediwash.css’]]
[dir: /home/sandbar/Desktop/Speediwash Webfiles/css]
[path: /home/sandbar/Desktop/nodeapp/node_modules/.bin:/home/sandbar/Desktop/nodeapp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-15-oracle/bin:/usr/lib/jvm/java-15-oracle/db/bin:/home/sandbar/bin:/usr/java/oracle/jdk-15.0.1/bin:/usr/lib/jvm/java-15-oracle/bin:/usr/lib/jvm/java-15-oracle/db/bin:/home/sandbar/bin:/usr/java/oracle/jdk-15.0.1/bin]

:thinking:

2 Likes

#10

I think you would do better to detail which scss plugins you use and what else you did to configure things so that changes to the .scss file are added to the related .css file on save.

That’s functionality I neither want nor need. Though if I wanted something like this I’d use a command line tool to watch for changes and trigger an external build system, rather than using a Sublime Text plugin. My point is simply that all of the things you’re seeing aren’t directly due to ST, it’s custom build systems, plugins and syntax definitions, none of which ST4 should change or affect.

2 Likes

#11

@jfcherng

Implemented suggested code amendment to the sass build config file and functional now. BTW please remove the comma after the last JSON entry in your config as other readers may be misled if it’s copied verbatim.

That is, make it like:

{
    "cmd": ["sass", "--update", "$file:${file_path}/…/css/${file_base_name}.css"],
    "selector": "source.sass, source.scss"
}

Now CRTL+S or CTRL+ALT+S only trigger SASS/SCSS updates if actual changes have been done on a .sass or .scss file.
Which is what I want. :yum:

0 Likes

#12

no, i am writing a st config, not a standard json thus a trailing comma is treated as a best practice imho. if another reader wants to read it, that’s its responsibility to deal with it (and comments).

1 Like

#13

I see.
Trailing Comma Behaviour For Config Entry

0 Likes