I have a directory full of less css files. What is the best way to compile them to normal css? (for deployment)
Id like to run a command as follows:
lessc -r less/ css/
where lessc is the less compiler (installed via node package manager)
Pre-compiling LESS into CSS: To compile LESS into CSS, we use the below command in a command prompt. The lessc command lets us precompile our LESS file into a basic CSS file. This helps us in writing modular code using LESS programming and still getting all the benefits of CSS by compiling it into traditional fast CSS.
When using the less file, which the browser doesn't understand as is, you need to include a Javascript LESS compiler which reads the less file and translates it to CSS which the browser does understand.
The way to do this is what bootstrap does - have a file which imports all the others and compile that.
@import "variables.less"; @import "mixins.less";
You can use the following bash one-liner to compile and all less files in a directory and its subdirectories into a single css file "combined.css":
$ find less_directory/ -name '*.less' -exec lessc {} \; > combined.css
Or minified for production:
$ find less_directory/ -name '*.less' -exec lessc -x {} \; > combined.css
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With