NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Recompile SCSS when saving


Joined: 11 May 2008
Posts: 79
Reply with quote
Is there a way to make Phped auto recompile SCSS files to CSS files when saving the SCSS version?
On Windows 7 x64 there seem to be critical problems with sass --watch command 1) it plain doesn't work at all (to detect changes), 2) its process uses considerable amount of CPU time and HDD doesn't stop to seek something until I stop the sass process. Confirmed on several machines.
Maybe some hook on saving the file, to execute the darn sass command. As a last resort I will accept any advice for third party watcher (not running the sass command and just hiding the terminal) that can run arbitrary commands.

I'm sorry for another, lateral, question. Does the latest version of Phped run on a standalone computer with no internet connection? I cannot be sure from the trial version because it is different from the purchased version. Because I saw something in another thread that made me wonder.
Thanks.

EDIT: It seems the best app I found is Koala, to auto-compile edited scss files. Still, it uses two additional resident processes to accomplish its task, it would be good if there is some built-in method to do that frmo inside the IDE. But this is Ok as long as Koala is bug-free (for now).
View user's profileFind all posts by tedychSend private message
Guru master

Joined: 24 Jul 2009
Posts: 717
Reply with quote
Magento has a reasonably complex SCSS structure, with around 66 files that get reduced down to 7 after being compiled. I use Ruby and Compass to do the compilation. For each project I create a watch.bat file in a work folder for that project that contains this command:

Code:
c:\Ruby193\bin\compass.bat watch full-path-to-scss-folder


Then when I'm working on SCSS, using PhpED I right-click and shell open that batch file, then shuffle that window where I can keep an eye on it. Using a consistent directory and method of opening the batch file ensures the sass-cache is located in the same place every time.

After doing an edit on any SCSS file it takes just a second to detect the changes, then it compiles within a few seconds. The watcher can be left running all day and doesn't seem to use a lot of resources. Doesn't bother me that it is a separate process and I prefer the separate window because it is not taking up IDE space.

PhpED runs great on a standalone computer.
View user's profileFind all posts by plugnplaySend private message


Joined: 11 May 2008
Posts: 79
Reply with quote
Thanks.
But doesn't compass watch use the same ruby watcher as sass --watch command? Also, having a terminal window open all the time in the taskbar is beyond my understanding of things. Koala on the other hand seems perfect for the needs: It is minimized to the tray and in case of compile error it displays an error message/balloon. It reacts instantly to file saves which is indispensable - it may be less than a second between I save a file in the IDE and switch to the browser and hit F5 to test. If the compiler doesn't react instantly, this can hinder productivity. 1-2 seconds would be acceptable but Koala recompiles instantly. You define all the projects you want to watch in it, and filter out anything but scss files. The top level project directory is enough.
I just start with SASS in general. I guess LESS is a no-go in phped for now.
View user's profileFind all posts by tedychSend private message
Guru master

Joined: 24 Jul 2009
Posts: 717
Reply with quote
I don't know if it uses the same watcher but i haven't had any of the issues you mentioned with it not detecting changes, using considerable CPU and HDD.

Over the last 12 hours it has used 1 hour of CPU from a single core, so whilst a reasonable amount on a typical 4 to 12 core system it isn't having any impact. Disk access is negligible.

I actually like the terminal window. I reduce down to just a few lines and shuffle it off to the edge of a monitor. When I make SCSS changes I can easily see how far it has got before I refresh a Magento page. Because Magento merges & caches the CSS, if I refresh the page too soon it causes problems.
View user's profileFind all posts by plugnplaySend private message


Joined: 11 May 2008
Posts: 79
Reply with quote
I see. The sass-only --watch'er spawns a ruby process. I'm currently on a 2 core system (typical are 4 core now, to 8 core i7s).
1 hour out of 12 hour lifetime is too much, especially when talking about a simple scss files watcher. Even my FF browser can't get so high in usage. This is about constant 9% on average over time. Too much. It should be almost zero while waiting for changes. Only when recompiling..
Disk usage - the ruby --watch'er didn't let the HDD LED go off at all. A Black WD. No idea what was happening in ruby's mind to cause that.
With Koala things are perfect Smile . And unless your S/CSS file is several megabytes long (+ any includes which should already be compiled because you are saving just one/the_current file), the compile should take less than a second.
Anyways, my "problem" can be considered solved.

About the other question, my worry was after I read a thread here that suggested there was a problem in Phped that would complain about the license if there is no internet connection.
View user's profileFind all posts by tedychSend private message
Guru master

Joined: 24 Jul 2009
Posts: 717
Reply with quote
That's an average of less than 1% CPU - I'm happy with that. Most days my Firefox uses a heck of a lot more than lot. The HDD light rarely even flashes.

The Magento SCSS totals 1.8MB and with 66 files a 3 second full compile is not unreasonable. Most changes create just 2 CSS output files and that takes less than a second, quicker than I can refresh a browser. Magento is also initially setup for Compass, so it was easy to get going.

I'm not aware of PhpED calling home, but it is certainly possible. Must admit I really dislike products that do that, particularly if they block product use when they can't call home.
View user's profileFind all posts by plugnplaySend private message


Joined: 11 May 2008
Posts: 79
Reply with quote
Yes, that was the point. If you use it on a laptop and you happen to travel or decide to work on vacation where there is not internet, you have all your assets with you, etc. Moreover, it happens the connection is lost for extended periods on bad weather etc.

About the scss - maybe the total is 1.8MB but as you said, you edit one file and when you save, all it has to do is compile that file alone, all other are already compiled, and even if you include bunch of files, they are just that - included and saved to as many resulting CSS'es as planned.
I was calculating the 1h/12h situation (on 1 core) - this is about 9% on average CPU usage (1 core). Again, it seems too much for only a watcher, day and night. Maybe it's polling which seems ridiculous. I guess Koala is using the proper method - hooks itself to directory changes and only "awakes" when being notified by the file system of a change.
Anyway, if that's the way you like it, it's ok Smile .
View user's profileFind all posts by tedychSend private message
Recompile SCSS when saving
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic