a simple file watcher for less files
npm install -g less-watchr
folder/
style.less
less-watchr --path folder/style.less
Listens at the folder/style.less
file and recompiles it when changes occur. Creates/updates the file folder/style.css
.
folder/
style.less
style2.less
less-watchr --path folder
Listens at the folder
folder and recompile the .less when changes occur. Creates/updates the file folder/style.css
or folder/style2.css
.
folder/
one.less
two.less
style.less
less-watchr --path folder --fileToCompile folder/style.less
Listens at the folder
folder and recompiles only the style.less after changes made at any .less file. Creates/updates the file folder/style.css
.
This is usefull when style.less is your main entry and uses @import.
folder/
folder1/
one.less
two.less
style.less
folder2/
one.less
two.less
style.less
less-watchr --config less-watchr-config.json
less-watchr-config.json
{
"path" : "folder",
"outputFilename" : "$1.css",
"fileToCompileMap" : [
{
"path": "folder/folder1/",
"fileToCompile" : "folder/folder1/style.less"
},
{
"path": "folder/folder2",
"fileToCompile" : "folder/folder2/style.less"
}
]
}
Listens at the folder
folder and recompiles folder/folder1/style.less
when changes in folder/folder1
occur. Same for folder/folder2
.
This is usefull you have different sections in one folder but still only want to use one less-watchr process.
folder/
folder1/
one.less
two.less
style.less
folder2/
one.less
two.less
style.less
global/
mixins.less
less-watchr --config less-watchr-config.json
less-watchr-config.json
{
"path" : "folder",
"outputFilename" : "$1.css",
"fileToCompileMap" : [
{
"path": "folder/folder1/",
"fileToCompile" : "folder/folder1/style.less"
},
{
"path": "folder/folder2",
"fileToCompile" : "folder/folder2/style.less"
},
{
"path": "folder/global",
"fileToCompile" : [
"folder/folder1/style.less",
"folder/folder2/style.less"
]
}
]
}
If something in folder folder/global
is changed it recompiles folder/folder1/style.less
and folder/folder2/style.less
.
Option path
can be an array.
less-watchr --path folder1 -path folder2
or
{
"path" : ["folder1", "folder2"],
}
You can define the ouput file name of the lessc compiler.
$1
will be replaced with the .less name.
less-watchr --outputFilename "$1.less.css"
or
less-watchr --outputFilename "hello.css"
now, if you want to set another path for outputfile, the path must be relative to the .less file location:
folder/
css/
style.css
folder1/
style.less
other.less
less-watchr --path folder/folder1/styles.less --outputFilename ../css/styles.css
Same in the config file.
With the options
you can pass options to the lessc compiler.
--options="--yui-compress"
Notice the = when you this argument