how to watch changes in whole directory/folder containing many sass files

CssSassBuild ProcessWatch

Css Problem Overview


How could I trace changes in whole directory containing many sass files ? I'm using the following command to watch changes in sass

file:

sass --watch style.scss:style.css

But how to watch changes in whole directory/folder containing many sass files.

Css Solutions


Solution 1 - Css

Simply use the command sass --watch <input folder>:<output folder>, like this:

$ ls -l
css/ sass/
$ sass --watch sass:css

Where <input folder> contains the Sass files and <output folder> that hosts the generated CSS files.

Solution 2 - Css

Expanding the answer by piouPiouM a little:

  • Output files will be created with the same names as input files except ending with .css.

  • <input folder> and <output folder> can be the same.

  • Both folders can be the present working directory, so the following is valid:

    $ sass --watch .:.

Solution 3 - Css

Go to you terminal and get to you folder then wrote:

 sass --watch .

this will watch all sass files and convert to css files with the same name. also you can do it in this way:

sass --watch ~/user/youUser/workspace/project/styles/

I hope this can help you.

Solution 4 - Css

I ended up doing this without using Grunt or Sass-watch:

npm install -g watch
watch "sass assets/app.scss assets/dist/app.css" assets/css

Solution 5 - Css

if you are in your current folder then do the following to watch it.

F:\sass tutorial>sass --watch ./:./

Solution 6 - Css

Just in case someone faces with this issue in 2018:
sass Website refers to Ruby Sass that is been deprecated. and as now (May 2018) if you install dart sass via npm , it does not support --watch command

What to do:
you need to install node-sass globaly , like:

npm install node-sass -g

and then restart the command line , then use this code:

node-sass --watch scss/styles.scss css/styles.css

to compile your scass files to css.
basically node-sass supports --watch command and we use that to compile our scss codes to regular css files.

and just in case you get an error like this at the first time that you save your .scss file:

{
  "status": 3,
  "message": "File to read not found or unreadable: yourdirectory/scss/styles.scss",
  "formatted": "Internal Error: File to read not found or unreadable: yourdirectory/scss/styles.scss\n"
}

what you need to do is save it again, it will work correctly!

Solution 7 - Css

According to the information, you can use the next command line:

sass --watch .

Source: http://sassbreak.com/watch-your-sass/#what-does---watch-do

Solution 8 - Css

You can create one sass file which includes the rest of the files, and then just watch this file.

Alternately, look into Grunt and the very good grunt-contrib-compass plugin

Solution 9 - Css

You can set sass to watch all the .scss files(for my case i got several .scss files in src/static folder) to compile, but before install it globally:

npm i -g sass

then go to the project folder and type command below:

sass --watch $(pwd)/src/static 

also you can wrap it in npm script in package.json, like

 "scripts": {
    "sass:watch": "sass --watch $(pwd)/src/static"
    }
    

and run it by this command:

npm run sass:watch

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJA9View Question on Stackoverflow
Solution 1 - CsspiouPiouMView Answer on Stackoverflow
Solution 2 - CssGary RobertsonView Answer on Stackoverflow
Solution 3 - CssdavthecoderView Answer on Stackoverflow
Solution 4 - CssmatskoView Answer on Stackoverflow
Solution 5 - Csssaransh mehraView Answer on Stackoverflow
Solution 6 - CssamdevView Answer on Stackoverflow
Solution 7 - CssMoises PortilloView Answer on Stackoverflow
Solution 8 - CsskumarharshView Answer on Stackoverflow
Solution 9 - CssArtem FedotovView Answer on Stackoverflow