node-sass icon indicating copy to clipboard operation
node-sass copied to clipboard

How can I watch and compile multiple directories?

Open golddragon007 opened this issue 5 years ago • 4 comments

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.)

golddragon007 avatar Apr 20 '20 11:04 golddragon007

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

saper avatar Apr 26 '20 23:04 saper

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

golddragon007 avatar May 06 '20 11:05 golddragon007

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.

Ismail-elkorchi avatar May 11 '20 07:05 Ismail-elkorchi

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 ?

yameenyasin avatar Jul 22 '20 16:07 yameenyasin