Dol*_*lev 2 less gulp gulp-less
我们使用 gulp-less 将 LESS 文件编译为 css。问题是我们在 less 文件中有 calc() 语句,我们希望 less 编译器按原样复制到 css,而不是在编译期间评估它们。
从命令行调用lessc时,这很容易使用
lessc --strict-math=on
Run Code Online (Sandbox Code Playgroud)
但是如何从 gulp 脚本中做到这一点?
我已经尝试将选项添加到任务参数中,如下所示:
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>));
});
Run Code Online (Sandbox Code Playgroud)
..但无济于事。是否可以?如果没有,任何解决方法或替代方法?
小智 6
破折号分隔的命名选项在javascript中的camelCase中,试试这个:
.pipe(less({
strictMath: 'on', // this is what you have to do
paths : [ <my less paths> ]
}))
Run Code Online (Sandbox Code Playgroud)