加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

gulp简单使用小记

发布时间:2020-12-14 23:56:21 所属栏目:资源 来源:网络整理
导读:div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px"npm install --save-dev 写入package.json里 div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px"? div style="white-space: pre-wrap; line-height: 1.875; f

<div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px">npm install --save-dev 写入package.json里
<div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; line-height: 1.875; font-size: 14px">var gulp = require('gulp');
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">var less = require('gulp-less');//less解析
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">var minifycss = require('gulp-minify-css');//css压缩
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">var uglify = require('gulp-uglify');js压缩
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">使用方法:
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">gulp.task('less',function() {
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; text-indent: 28px; font-size: 14px">gulp.src('./css/.css')//压缩的文件
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; text-indent: 56px; font-size: 14px">.pipe(less())//执行压缩
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; text-indent: 56px; font-size: 14px">.pipe(gulp.dest('./css'));//输出文件夹
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">});
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">....
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">//watch监听任务
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">gulp.task('watch',function(){
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; text-indent: 28px; font-size: 14px">gulp.watch('./css/
.css',['less'] )//gulp的watch监听,文件改动后立即重新执行less任务
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">})
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">gulp.task('default',['less',...]);//执行以上方法
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">单独介绍:
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">var combiner = require('stream-combiner2');//监控合并时候文件本身的错误
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">?
<div style="white-space: pre-wrap; text-align: left; line-height: 1.875; font-size: 14px">默认情况下,在 stream 中发生一个错误的话,它会被直接抛出,除非已经有一个时间监听器监听着 <span style="font-family: monospace">error 时间。 这在处理一个比较长的管道操作的时候会显得比较棘手。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读