//tip1、gulp任务是异步的,task写法上可以省略return,但在需要同步执行任务时,这个return是不能省略的。//tip2、安装gulp时,一定要全局安装一个,项目依赖安装一个,要使用gulp的命令必须全局安装/** 1.为了减少http请求,把三个js合并成一个js,* 2.为了减少js请求的加载时间,把合并后的js压缩成一个min.js* 3.原来的三个js已经变成了一个js.需要把输出的jsp文件里的三个')) .pipe(htmlmin(options)) .pipe(gulp.dest('dev/'));});// gulp.task('del_script',function(){// return gulp .src('GF-WIFI/*.html')// .pipe(gulp.dest('dev'))// // return gulp.src('GF-WIFI/*.html')// // .pipe(cheerio(function($){// // if($('script')){// // console.log('数据%o',$('script'))// // $('script').remove();// // $('body').append('')//这个会为每一个html加这个压缩合并的js// // }// // }))// // // .pipe(htmlmin())// // .pipe(gulp.dest('dev'))// })//将img里面的图片转到其他目录gulp.task('move_img',function(){ return gulp.src('GF-WIFI/img/*.*') .pipe(gulp.dest('dev/img'))})gulp.task('default', gulpSequence( ['del'], ['hebing_js'],['hebing_css'],['minhtml'],['move_img'],['watch_css']))gulp.task('watch_css',function(){ gulp.watch('GF-WIFI/css/*.css',function(event){ switch(event.type){ case 'deleted': break case 'added': break case 'changed': gutil.log(event.path + ' changed') // var target = event.path.match(/src[\/|\\](.*?)[\/|\\]/)[1] // gulp.src(path.dirs.src + target + '/**/*.*') // .pipe(gulp.dest(path.dirs.dev + target)) break } })})// gulp.task('hebing_css',function(){// var px_rem=[px2rem({// remUnit:75// })]// return gulp.src('GF-WIFI/css/*.css')// .pipe(concat('main.css'))// .pipe(clean_css())// .pipe(gulp_autoprefixer({// browsers: ['last 2 versions', 'Android >= 4.0'],// cascade: true, //是否美化属性值 默认:true 像这样:// //-webkit-transform: rotate(45deg);// // transform: rotate(45deg);// remove:true //是否去掉不必要的前缀 默认:true// }))// .pipe(postcss(px_rem))// .pipe(gulp.dest('dev/css'))// })// // gulp.task('default', function() {// // // 将你的默认的任务代码放在这// // gulp.start('del','hebing_js','hebing_css');// // })// gulp.task('default', function() {// // 将你的默认的任务代码放在这// gulp.start('del','hebing_js','hebing_css','del_script','move_img');// })// gulp.task('test',function(){// console.log('ceshi')// })//编译的lessgulp.task('less',function(){ return gulp.src('learn_less/less/*.*') .pipe( less().on('error', function (e) { console.error(e.message) this.emit('end') }) ) .pipe(gulp.dest('learn_less/css'))})