sass / node-sass

:rainbow: Node.js bindings to libsass
https://npmjs.org/package/node-sass
MIT License
8.51k stars 1.32k forks source link

How can I watch and compile multiple directories? #2894

Open golddragon007 opened 4 years ago

golddragon007 commented 4 years ago

Hello,

I really thought to leave grunt and use the native command line to be able to use the built-in --watch option. But I've faced some issue. I not really fount any documentation for the command-line way. I have the following structure: lib/module/*/sass/* lib/theme//sass/** In the sass directory in the root, there are the files which include other components from subdirectories. I want to watch every file but translate only without a starting '_' into CSS. (this is normal) However, I want to place to their own directories CSS directory. i.e.: lib/module/first/sass/something.scss -> lib/module/first/css/something.css lib/module/first/sass/something2.scss -> lib/module/first/css/something2.css lib/module/second/sass/something.scss -> lib/module/second/css/something.css lib/theme/my_theme/sass/style.scss -> lib/theme/my_theme/css/style.css

I don't want to use grunt or gulp for this, just pure command line, so I will be able to use the --watch option. Also, I don't want to use static mapping. Can somebody help me how can I reach this? (If possible to do it.)

saper commented 4 years ago

We provide only rudimentary watch facility (and it is not fully working even).

golddragon007 commented 4 years ago

Oh, I see. Then probably this is not the way how it will happen.

Ismail-elkorchi commented 4 years ago

If you are using npm, you can add a custom script to your package.json that runs the following script :

( node-sass lib/module/sass/ -o  lib/module/css/ --source-map true --output-style expanded -w ) & ( node-sass lib/theme/sass/ -o  lib/theme/css/ --source-map true --output-style expanded -w )

Note that this command will watch all the SASS files under lib/module/sass and lib/theme/sass and will output the resulting CSS files to lib/module/css and lib/theme/css.

yameenyasin commented 4 years ago

If you are using npm, you can add a custom script to your package.json that runs the following script :

( node-sass lib/module/sass/ -o  lib/module/css/ --source-map true --output-style expanded -w ) & ( node-sass lib/theme/sass/ -o  lib/theme/css/ --source-map true --output-style expanded -w )

Note that this command will watch all the SASS files under lib/module/sass and lib/theme/sass and will output the resulting CSS files to lib/module/css and lib/theme/css.

is there a way to do the same using node-sass.render api ?