Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compiling less from gulp with options

We're using gulp-less to compile LESS files to css. The problem is that we have calc() statements in the less files which we want the less compiler to copy over to the css as-is, instead of evaluating them during compilation.

When invoking lessc from the command line, this is easily done using

lessc --strict-math=on

But how to do it from the gulp script?

I've tried adding the option to the task parameter, like so:

gulp.task('less', function() {
  return gulp.src(<my less files>)
             .pipe(less({
                       'strict-math': 'on',    // this is what I tried to add
                        paths : [ <my less paths> ]
                     }))
             .pipe(gulp.dest(<my css path>));
});

.. but to no avail. Is it possible? Any work-arounds or alternatives if not?

like image 982
Dolev Avatar asked Aug 09 '26 13:08

Dolev


1 Answers

Dash separated named options are in camelCase in javascript, try this :

 .pipe(less({
      strictMath: 'on',    // this is what you have to do
      paths : [ <my less paths> ]
 }))
like image 168
Arnaud Gueras Avatar answered Aug 11 '26 10:08

Arnaud Gueras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!