1.创建:gulpfile.js
var gulp = require('gulp'),
less = require('gulp-less'); gulp.task('default', function () {
gulp.src('less/index.less')
.pipe(less())
.pipe(gulp.dest('dist'));
});
2.创建package.json
npm init
3.安装gulp到项目
npm install --save-dev gulp
4.安装插件到项目:
npm install gulp-less --save-dev
5.准备的less/index.css
@color:#ff0000;
body{color:@color;}
6.目录下运行:
gulp
效果输出:
dist/app.css
body {
color: #ff0000;
}