pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<tfoot id='uvhDM'></tfoot>

    <legend id='uvhDM'><style id='uvhDM'><dir id='uvhDM'><q id='uvhDM'></q></dir></style></legend>

      <bdo id='uvhDM'></bdo><ul id='uvhDM'></ul>
    <i id='uvhDM'><tr id='uvhDM'><dt id='uvhDM'><q id='uvhDM'><span id='uvhDM'><b id='uvhDM'><form id='uvhDM'><ins id='uvhDM'></ins><ul id='uvhDM'></ul><sub id='uvhDM'></sub></form><legend id='uvhDM'></legend><bdo id='uvhDM'><pre id='uvhDM'><center id='uvhDM'></center></pre></bdo></b><th id='uvhDM'></th></span></q></dt></tr></i><div class="hfbhvlv" id='uvhDM'><tfoot id='uvhDM'></tfoot><dl id='uvhDM'><fieldset id='uvhDM'></fieldset></dl></div>

    <small id='uvhDM'></small><noframes id='uvhDM'>

    1. javascript, gulp, 觀看, 改變

      javascript, gulp, watch, changed(javascript, gulp, 觀看, 改變)

      <small id='6KjhU'></small><noframes id='6KjhU'>

        <bdo id='6KjhU'></bdo><ul id='6KjhU'></ul>

              <tbody id='6KjhU'></tbody>

            • <tfoot id='6KjhU'></tfoot>

                <legend id='6KjhU'><style id='6KjhU'><dir id='6KjhU'><q id='6KjhU'></q></dir></style></legend>
                <i id='6KjhU'><tr id='6KjhU'><dt id='6KjhU'><q id='6KjhU'><span id='6KjhU'><b id='6KjhU'><form id='6KjhU'><ins id='6KjhU'></ins><ul id='6KjhU'></ul><sub id='6KjhU'></sub></form><legend id='6KjhU'></legend><bdo id='6KjhU'><pre id='6KjhU'><center id='6KjhU'></center></pre></bdo></b><th id='6KjhU'></th></span></q></dt></tr></i><div class="rzfx7jt" id='6KjhU'><tfoot id='6KjhU'></tfoot><dl id='6KjhU'><fieldset id='6KjhU'></fieldset></dl></div>
              • 本文介紹了javascript, gulp, 觀看, 改變的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時送ChatGPT賬號..

                我無法理解這一點.這應(yīng)該是每次修改監(jiān)視文件時執(zhí)行的 gulp 任務(wù).誰能解釋為什么需要通過 changed 插件來管道監(jiān)視的文件?

                I cannot get my head around this. This is supposed to be a gulp task that is executed every time a watched file is modified. Can anyone explain why it is required to pipe the watched files through the changed plugin?

                gulp.task('build-css', function () {
                  return gulp.src(paths.css)
                  .pipe(changed(paths.output, {extension: '.css'}))
                  .pipe(gulp.dest(paths.output));
                });
                
                gulp.task('watch', ['serve'], function() { 
                  gulp.watch(paths.css, ['build-css']); 
                }); 
                

                免責(zé)聲明:這不是我的代碼.只是想了解發(fā)生了什么,以便創(chuàng)建我自己的自定義監(jiān)視任務(wù).

                Disclaimer: this is not my code. Just trying to understand what is going on, in order to create my own custom watch task.

                推薦答案

                gulp.watch()gulp-changedgulp-watch的區(qū)別 似乎引起了很多混亂,所以這是我解開混亂的嘗試:

                The difference between gulp.watch(), gulp-changed and gulp-watch seems to cause a lot of confusion, so here's my attempt at untangling the mess:

                這是 gulp 本身 的一部分,而不是插件.這很重要,因為這意味著與其他兩個不同,它不會傳遞給 gulp 流的 pipe() 函數(shù).

                相反,它通常直接從 gulp 任務(wù)內(nèi)部調(diào)用:

                Instead it is usually called directly from inside a gulp task:

                 gulp.task('build-css', function() { 
                    return gulp.src('src/**/*.css')
                      .pipe(doSomethingHere())
                      .pipe(gulp.dest('dist/css'));
                 }); 
                
                 gulp.task('watch', function() { 
                    gulp.watch('src/**/*.css', ['build-css']); 
                 }); 
                

                上面的gulp.watch()用來監(jiān)聽.css文件的變化.只要 gulp.watch() 正在運行對 .css 文件的任何更改,就會自動執(zhí)行 build-css 任務(wù).

                In the above gulp.watch() is used to listen for changes in .css files. As long as gulp.watch() is running any change to a .css file automatically results in the execution of the build-css task.

                這就是麻煩的開始.請注意沒有關(guān)于哪些文件發(fā)生更改的信息傳遞給 build-css?這意味著即使您僅更改單個 .css 文件 all 您的 .css 文件也將通過 doSomethingHere()再次.build-css 任務(wù)不知道它們中的哪一個發(fā)生了變化.只要您只有一手文件,這可能沒問題,但隨著文件數(shù)量的增加,您的構(gòu)建速度會變慢.

                This is where the trouble starts. Notice how no information about which files where changed is passed to build-css? That means even if you change just a single .css file all of your .css files will pass through doSomethingHere() again. The build-css task has no clue which of them changed. This may be fine as long as you have only a hand full of files, but can slow down your build as the number of files grows.

                這就是 gulp-changed 的用武之地.

                That's where gulp-changed comes in.

                這個 插件 被編寫為在 gulp 流中充當(dāng)過濾器階段.其目的是從流中刪除自上次構(gòu)建以來未更改的所有文件.它通過將源目錄中的文件與目標(biāo)目錄中的結(jié)果文件進行比較來做到這一點:

                This plugin was written to act as a filter stage in a gulp stream. Its purpose is to remove all those files from a stream that haven't changed since the last build. It does this by comparing the files in the source directory with the resulting files in the destination directory:

                 gulp.task('build-css', function() { 
                    return gulp.src('src/**/*.css')
                      .pipe(changed('dist/css'))  //compare with files in dist/css
                      .pipe(doSomethingHere())
                      .pipe(gulp.dest('dist/css'));
                 }); 
                
                 gulp.task('watch', function() { 
                    gulp.watch('src/**/*.css', ['build-css']); 
                 }); 
                

                在上面的 build-css 任務(wù)仍然為 .css 文件的每次更改調(diào)用,并且所有 .css 文件都被讀取然而,只有那些實際更改過的文件現(xiàn)在到達昂貴的 doSomethingHere() 階段.其余的被 gulp-changed 過濾掉.

                In the above the build-css task is still called for every change of a .css file and all .css files are read in. However only those files that were actually changed now reach the expensive doSomethingHere() stage. The rest is filtered out by gulp-changed.

                這種方法的好處是可以加快 build-css 的速度,即使您不關(guān)注文件更改.您可以在命令行上顯式調(diào)用 gulp build-css,并且只有自上次調(diào)用 build-css 后發(fā)生更改的文件才會被重建.

                This approach has the benefit of speeding up build-css even if you're not watching for file changes. You can explicitly invoke gulp build-css on the command-line and only those files that have changed since the last invocation of build-css will be rebuilt.

                這個 插件 是對內(nèi)置 gulp 的改進嘗試.watch().而 gulp.watch() 使用 gaze 監(jiān)聽文件變化,gulp-watch 使用 chokidar 一般認為是兩者中比較成熟的一個.

                This plugin is an attempt to improve on the built-in gulp.watch(). While gulp.watch() uses gaze to listen for file changes, gulp-watch uses chokidar which is generally considered to be the more mature of the two.

                你可以使用 gulp-watch 來達到與使用 gulp.watch()gulp-changed 組合的效果:

                You can use gulp-watch to achieve the same effect as using gulp.watch() and gulp-changed in combination:

                 gulp.task('watch-css', function() { 
                    return gulp.src('src/**/*.css')
                      .pipe(watch('src/**/*.css'))
                      .pipe(doSomethingHere())
                      .pipe(gulp.dest('dist/css'));
                 }); 
                

                這再次監(jiān)視所有 .css 文件的更改.但是這一次,每當(dāng) .css 文件被更改時,該文件(以及 only 該文件)會再次被讀入并重新發(fā)送到它通過 doSomethingHere 的流中() 在前往目標(biāo)目錄的途中.

                This again watches all .css files for changes. But this time whenever a .css file is changed, that file (and only that file) is read in again and reemitted to the stream where it passes through doSomethingHere() on its way to the destination directory.

                請注意,此比較以相當(dāng)寬泛的筆觸描繪了所有三個替代方案,并遺漏了某些細節(jié)和功能(例如,我沒有討論您可以傳遞給這兩個的回調(diào)函數(shù) gulp.watch()gulp-watch),但我認為這應(yīng)該足以了解這三者之間的主要區(qū)別.

                Note that this comparison paints all three of the alternatives in rather broad strokes and leaves out certain details and features (e.g. I haven't talked about the callback functions that you can pass to both gulp.watch() and gulp-watch), but I think this should be enough to get the major differences between the three across.

                這篇關(guān)于javascript, gulp, 觀看, 改變的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標(biāo)志傳遞給 Gulp 以使其以不同的方式運行任務(wù)?)
                Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務(wù))
                Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                    <tbody id='0R9Yv'></tbody>

                  <legend id='0R9Yv'><style id='0R9Yv'><dir id='0R9Yv'><q id='0R9Yv'></q></dir></style></legend>

                  <tfoot id='0R9Yv'></tfoot>
                      <bdo id='0R9Yv'></bdo><ul id='0R9Yv'></ul>

                          <small id='0R9Yv'></small><noframes id='0R9Yv'>

                        • <i id='0R9Yv'><tr id='0R9Yv'><dt id='0R9Yv'><q id='0R9Yv'><span id='0R9Yv'><b id='0R9Yv'><form id='0R9Yv'><ins id='0R9Yv'></ins><ul id='0R9Yv'></ul><sub id='0R9Yv'></sub></form><legend id='0R9Yv'></legend><bdo id='0R9Yv'><pre id='0R9Yv'><center id='0R9Yv'></center></pre></bdo></b><th id='0R9Yv'></th></span></q></dt></tr></i><div class="yeomlva" id='0R9Yv'><tfoot id='0R9Yv'></tfoot><dl id='0R9Yv'><fieldset id='0R9Yv'></fieldset></dl></div>
                          主站蜘蛛池模板: 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | 锡膏喷印机-全自动涂覆机厂家-全自动点胶机-视觉点胶机-深圳市博明智控科技有限公司 | 蜂窝块状沸石分子筛-吸附脱硫分子筛-萍乡市捷龙环保科技有限公司 | 硫酸钡厂家_高光沉淀硫酸钡价格-河南钡丰化工有限公司 | 郑州大巴车出租|中巴车租赁|旅游大巴租车|包车|郑州旅游大巴车租赁有限公司 | 福州仿石漆加盟_福建仿石漆厂家-外墙仿石漆加盟推荐铁壁金钢(福建)新材料科技有限公司有保障 | 聚丙烯酰胺PAM-聚合氯化铝PAC-絮凝剂-河南博旭环保科技有限公司 巨野电机维修-水泵维修-巨野县飞宇机电维修有限公司 | 山东活动策划|济南活动公司|济南公关活动策划-济南锐嘉广告有限公司 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 垃圾清运公司_环卫保洁公司_市政道路保洁公司-华富环境 | 球盟会·(中国)官方网站 | 金联宇电缆总代理-金联宇集团-广东金联宇电缆实业有限公司 | 威廉希尔WilliamHill·足球(中国)体育官方网站 | 西安烟道厂家_排气道厂家_包立管厂家「陕西西安」推荐西安天宇烟道 | 高效节能电机_伺服主轴电机_铜转子电机_交流感应伺服电机_图片_型号_江苏智马科技有限公司 | 【中联邦】增稠剂_增稠粉_水性增稠剂_涂料增稠剂_工业增稠剂生产厂家 | 深圳成考网-深圳成人高考报名网 深圳工程师职称评定条件及流程_深圳职称评审_职称评审-职称网 | 炒货机-炒菜机-炒酱机-炒米机@霍氏机械| 北京租车公司_汽车/客车/班车/大巴车租赁_商务会议/展会用车/旅游大巴出租_北京桐顺创业租车公司 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 山楂片_雪花_迷你山楂片_山楂条饼厂家-青州市丰源食品厂 | 自动配料系统_称重配料控制系统厂家 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 1000帧高速摄像机|工业高速相机厂家|科天健光电技术 | 垃圾压缩设备_垃圾处理设备_智能移动式垃圾压缩设备--山东明莱环保设备有限公司 | 不锈钢轴流风机,不锈钢电机-许昌光维防爆电机有限公司(原许昌光维特种电机技术有限公司) | 茅茅虫AI论文写作助手-免费AIGC论文查重_写毕业论文降重 | 校车_校车价格_19座幼儿园校车_幼儿园校车_大鼻子校车 | 柔性测斜仪_滑动测斜仪-广州杰芯科技有限公司| 球磨机,节能球磨机价格,水泥球磨机厂家,粉煤灰球磨机-吉宏机械制造有限公司 | 吉林污水处理公司,长春工业污水处理设备,净水设备-长春易洁环保科技有限公司 | 慈溪麦田广告公司,提供慈溪广告设计。 | 微学堂-电动能源汽车评测_电动车性能分享网 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 气动隔膜泵厂家-温州永嘉定远泵阀有限公司 | 上海物流公司,上海货运公司,上海物流专线-优骐物流公司 | 网站制作优化_网站SEO推广解决方案-无锡首宸信息科技公司 | 余姚生活网_余姚论坛_余姚市综合门户网站 | 礼仪庆典公司,礼仪策划公司,庆典公司,演出公司,演艺公司,年会酒会,生日寿宴,动工仪式,开工仪式,奠基典礼,商务会议,竣工落成,乔迁揭牌,签约启动-东莞市开门红文化传媒有限公司 | 深圳货架厂家_金丽声精品货架_广东金丽声展示设备有限公司官网 | 合肥白癜风医院_合肥治疗白癜风医院_合肥看白癜风医院哪家好_合肥华研白癜风医院 |