一、从零开始搭建gulp前端自动化
1、首先安装nodejs
2、npm init生成package.json
2、定位到当前目录 cd.. d: 我在d盘新建了文件夹gulp
3、npm install --save-dev 安装gulp
4、新建gulpfile.js 需要安装npm install --save-dev gulp-less | npm install --save-dev gulp-uglify | npm install --save-dev gulp-autoprefixer
var gulp = require("gulp"), less = require("gulp-less"), uglify = require("gulp-uglify"), autoprefixer = require("gulp-autoprefixer"); gulp.task(‘testLess‘,function(){ gulp.src(‘src/less/index.less‘) .pipe(less()) .pipe(gulp.dest(‘src/css‘)); }); //gulp.task(‘default‘,[‘testLess‘,‘elseTask‘]); gulp.task(‘jsMin‘,function(){ gulp.src([‘src/js/*.js‘]) .pipe(uglify()) .pipe(gulp.dest(‘dist/js‘)); }); gulp.task(‘testAutoFx‘,function(){ gulp.src([‘src/css/my.css‘]) .pipe(autoprefixer({ browsers:[‘last 2 versions‘,‘Android >=4.0‘], cascade:true, remove:true })) .pipe(gulp.dest(‘dist/css‘)) });
参考文章http://www.ydcss.com/
时间: 2024-10-13 22:55:32