We are using NodeJS to build our project. We have integrated LESS CSS as a part of the project. We are attempting to keep our build clean and would like to be able to call the lessc command (or something comparable) in order to build our LESS files.
The LESS documentation isn't very in depth, but wanted to reach out to the community to find a solution. Google has not be too helpful to me on this topic.
We have a build.sh file, that calls various other build.js files (in respective directories). How can I run LESSC to compile my LESS files?
It has additions such as variables, mixins, operations, and functions. They help make the code cleaner and easier to maintain. Creating and Storing a LESS File: Step 1: Go to your project folder, create a subfolder named CSS and then create a file named styles.
Most likely you need to compile you're Less Files into CSS. You can do this manually, or with a task runner like Gulp. If you already have compiled the file, it could be that the compiled css file is cached in the browser and the browser cache needs to be cleared.
Make sure you include your stylesheets before the script. You should compile your less-file to css-file and include it in your <head> -section as is without any less- or js-files.
Using Less. js in the browser is the easiest way to get started and convenient for developing with Less, but in production, when performance and reliability is important, we recommend pre-compiling using Node.
Using node.js
var less = require('less')
,fs = require('fs');
fs.readFile('style.less',function(error,data){
data = data.toString();
less.render(data, function (e, css) {
fs.writeFile('style.css', css, function(err){
console.log('done');
});
});
});
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