博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gulp备忘录
阅读量:6916 次
发布时间:2019-06-27

本文共 2796 字,大约阅读时间需要 9 分钟。

hot3.png

//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'))})

转载于:https://my.oschina.net/u/3407699/blog/1800551

你可能感兴趣的文章
RVM 安装与使用帮助
查看>>
Tomcat性能调优方案
查看>>
Ubuntu12.04上编译PlateGatewayQt
查看>>
(转)UITableView使用详解 相当详细,不错的东东
查看>>
Java中JDK,JRE和JVM之间的关系
查看>>
Python-NLTK环境搭建
查看>>
linux下的usb抓包方法【转】
查看>>
二叉搜索树转换成有序的双向链表
查看>>
内核定时器的使用(好几个例子add_timer)【转】
查看>>
linux中高端内存和低端内存的概念【转】
查看>>
软件整合--硬件整合--平台整合
查看>>
maven中properties标签定义变量
查看>>
Linux下路由配置梳理
查看>>
9.2. frame
查看>>
sql获取每门课程成绩最好的学生信息
查看>>
VS输出窗口(output view)的小技巧--文件行号字符定位
查看>>
[UIView beginAnimations:context:]与[UIView animateWithDuration:animations:]值得注意的一个区别...
查看>>
U3D的飞船太空射击例子中,使用coroutine
查看>>
Alibaba Cloud MaxCompute vs. AWS Redshift vs. Azure SQL Data Warehouse
查看>>
浅谈数据库用户表结构设计,第三方登录
查看>>