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:
The above assumes there is only one job running in the background. If you not sure about this, run:
To stop current command press Ctrl+Z simultaneously. To resume the job type:
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!
Author, Copyright and citation
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.
©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.
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