gulp-less安装方法
npm install gulp-less
Basic Usage
var less = require('gulp-less'); var path = require('path'); gulp.task('less', function () { return gulp.src('./less/**/*.less') //要编译的源文件的地址 .pipe(less({ paths: [ path.join(__dirname, 'less', 'includes') ] })) .pipe(gulp.dest('./public/css')); //编译成功后的目的文件夹 });
sourceMap使用 (需要先安装 npm install -g gulp-sourcemaps)
var sourcemaps = require('gulp-sourcemaps'); gulp.src('./less/**/*.less') .pipe(sourcemaps.init()) .pipe(less()) .pipe(sourcemaps.write()) .pipe(gulp.dest('./public/css'));