Make sass watch and compile scss files in the background

Make sass watch and compile scss files in the background

Created:11 Jan 2022 00:42:58 , in  Web development

In this short article I look at how to make sass command watch and compile scss file in the background. If you run sass on the command line with --watch switch, it will block your terminal. You can regain access to the console with Ctrl+C, which will kill the process, or just put sass in the background and continue using the same terminal window for other commands.

If you haven't got sass command line utility on your system, you can install it like this ( assuming you have node and npm installed):


npm i -g sass

To compile file style.scss to style.css every time when style.scss gets saved type:


sass --watch style.scss style.css &> /dev/null &

to bring the job back to foreground:


fg %1

The above assumes there is only one job running in the background. If you not sure about this, run:


jobs

To stop current command press Ctrl+Z simultaneously. To resume the job type:


fg %1

Often If you use sass on the command line, it is not a bad idea to keep it in the background and watching for .scss file changes. The technique described here works equally well for larger number of .scss files as well as directories. If you need to see output sass produces, remove redirection bit starting after &> and ending before &. Have fun!

Tags:  Sass 


Author, Copyright and citation

Author

Sylwester Wojnowski

Author of the this article - Sylwester Wojnowski - is a sWWW web developer. He has been writing computer code for the websites and web applications since 1998.

Copyrights

©Copyright, 2022 Sylwester Wojnowski. This article may not be reproduced or published as a whole or in parts without permission from the author. If you share it, please give author credit and do not remove embedded links.

Computer code, if present in the article, is excluded from the above and licensed under GPLv3.

Citation

Cite this article as:

Wojnowski, Sylwester. "Make sass watch and compile scss files in the background." From sWWW - Code For The Web . https://wojnowski.net.pl//main/index/make-sass-watch-and-compile-scss-files-in-the-background

Add Comment

Allowed BB Code - style tags: [b][/b], [i][/i], [code=text][/code],[code=javascript][/code],[code=php][/code],[code=bash][/code],[code=css][/code],[code=html][/code]


I constent to processing my data given through this form for purposes of a reply by the administrator of this website.

Recent Comments

Nobody has commented on this post yet. Be first!