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

  • <tfoot id='9ooJB'></tfoot>

  • <legend id='9ooJB'><style id='9ooJB'><dir id='9ooJB'><q id='9ooJB'></q></dir></style></legend>

      <small id='9ooJB'></small><noframes id='9ooJB'>

        <bdo id='9ooJB'></bdo><ul id='9ooJB'></ul>
      <i id='9ooJB'><tr id='9ooJB'><dt id='9ooJB'><q id='9ooJB'><span id='9ooJB'><b id='9ooJB'><form id='9ooJB'><ins id='9ooJB'></ins><ul id='9ooJB'></ul><sub id='9ooJB'></sub></form><legend id='9ooJB'></legend><bdo id='9ooJB'><pre id='9ooJB'><center id='9ooJB'></center></pre></bdo></b><th id='9ooJB'></th></span></q></dt></tr></i><div class="yy40uwe" id='9ooJB'><tfoot id='9ooJB'></tfoot><dl id='9ooJB'><fieldset id='9ooJB'></fieldset></dl></div>
      1. 使用 Browserify 和 Gulp 使用共享的公共庫(kù)創(chuàng)建單獨(dú)

        Create separate JavaScript bundles with a shared common library using Browserify and Gulp(使用 Browserify 和 Gulp 使用共享的公共庫(kù)創(chuàng)建單獨(dú)的 JavaScript 包)

          <legend id='kWdFK'><style id='kWdFK'><dir id='kWdFK'><q id='kWdFK'></q></dir></style></legend>
          <i id='kWdFK'><tr id='kWdFK'><dt id='kWdFK'><q id='kWdFK'><span id='kWdFK'><b id='kWdFK'><form id='kWdFK'><ins id='kWdFK'></ins><ul id='kWdFK'></ul><sub id='kWdFK'></sub></form><legend id='kWdFK'></legend><bdo id='kWdFK'><pre id='kWdFK'><center id='kWdFK'></center></pre></bdo></b><th id='kWdFK'></th></span></q></dt></tr></i><div class="4uwmesk" id='kWdFK'><tfoot id='kWdFK'></tfoot><dl id='kWdFK'><fieldset id='kWdFK'></fieldset></dl></div>
        • <tfoot id='kWdFK'></tfoot>

                <tbody id='kWdFK'></tbody>

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

                • <bdo id='kWdFK'></bdo><ul id='kWdFK'></ul>
                • 本文介紹了使用 Browserify 和 Gulp 使用共享的公共庫(kù)創(chuàng)建單獨(dú)的 JavaScript 包的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  對(duì)于我的工作團(tuán)隊(duì),我正在嘗試在 Gulp 和 Browserify 的幫助下建立一個(gè)半自動(dòng)化 JavaScript 腳本和依賴管理系統(tǒng).

                  我什至不確定使用當(dāng)前可用的工具集(以及我有限的 JavaScript 知識(shí))是否可以實(shí)現(xiàn)我想要實(shí)現(xiàn)的目標(biāo).我相信我想要實(shí)現(xiàn)的是一個(gè)非常常見(jiàn)的場(chǎng)景,但我無(wú)法找到我一直在尋找的信息.

                  考慮下圖:

                  線條表示依賴關(guān)系.對(duì)于共享模塊,例如 Module-vModule-y,我不希望通過(guò)包含在它們各自的包中來(lái)復(fù)制腳本.p>

                  我知道使用 Browserify 我可以手動(dòng)忽略或排除模塊,這在項(xiàng)目還很年輕時(shí)很好 - 但隨著項(xiàng)目的增長(zhǎng),管理需要包含哪些依賴項(xiàng)將變得非常麻煩.

                  我認(rèn)為這里有一個(gè) 類似的問(wèn)答我要問(wèn)的本質(zhì)相同,但對(duì)我來(lái)說(shuō),還不是很清楚.它還引用了 gulp-browserify,它已被列入黑名單.

                  在我的圖表中,我可以看到我有三個(gè) Browserify 入口點(diǎn),但我缺乏 Gulp/Node/Browserify 經(jīng)驗(yàn)意味著我正在努力思考如何嘗試實(shí)現(xiàn)我想要的.

                  我很高興能夠嘗試將其拼湊起來(lái),正如我已經(jīng)嘗試過(guò)的那樣 - 但是項(xiàng)目經(jīng)理正在喘不過(guò)氣來(lái),所以我不得不拼湊一個(gè)臨時(shí)的解決方案",直到我可以實(shí)施一些更自動(dòng)化和更強(qiáng)大的東西.

                  提前致謝.

                  編輯

                  從 Browserify 的插件文檔看來(lái),這可能可以通過(guò)使用 factor-bundle 其中 子棧 指出給我;然而,由于我缺乏 Node/Browserify/Gulp 經(jīng)驗(yàn),我再次努力將所有部分整合在一起.

                  相關(guān)問(wèn)題

                  • 如何以編程方式將 factor-bundle 與 browserify 一起使用?

                  解決方案

                  想通了,分享經(jīng)驗(yàn):

                  代碼示例:

                  var gulp = require('gulp'),source = require('vinyl-source-stream'),browserify = require('browserify'),因子 = 要求(因子捆綁");gulp.task('瀏覽器', function(){返回瀏覽器化({條目:['blog.js', 'page.js']}).plugin(因素,{//文件輸出順序必須與入口順序一致o: ['bundle/blog.js', 'bundle/page.js']}).捆({調(diào)試:真}).pipe(source('common.js')).pipe(gulp.dest('bundle/'));});

                  此輸出與圖表的主要區(qū)別在于,common.js 文件是根據(jù) blog.jspage 之間的共同依賴關(guān)系自動(dòng)生成的.js.這在 factor-bundle 文檔中有描述.

                  注意事項(xiàng):

                  • 我發(fā)現(xiàn)如果輸出文件不存在,Node 會(huì)拋出錯(cuò)誤.我不確定為什么我會(huì)假設(shè) factor-bundle 只是將流寫(xiě)入輸出文件,而不管它是否存在.作為一種解決方法,在清理"輸出目錄之后,我只是創(chuàng)建了占位符"文件以保持其正常運(yùn)行.

                  • 我還沒(méi)弄清楚如何訪問(wèn) factor-bundle 流事件 當(dāng)將其用作 browserify 插件時(shí)(甚至可能無(wú)法實(shí)現(xiàn)),因此對(duì)輸出文件的任何進(jìn)一步工作(例如 uglifying 等)都可能需要在管道中的其他地方完成,可能需要使用另一個(gè) browserify 插件,甚至事后.

                  For my team at work, I'm trying to set up a semi-automated JavaScript script and dependency management system with the help of Gulp and Browserify.

                  I'm not even sure if what I'm trying to achieve is possible with the currently available set of tools (and my limited JavaScript knowledge). I believe what I'm trying to achieve is a pretty common scenario, but I haven't been able to find the information I've been looking for.

                  Consider the following diagram:

                  The lines indicate depedencies. For shared modules, such as Module-v and Module-y, I don't want the scripts to be duplicated by being included in each of their respective bundles.

                  I know that using Browserify I can manually ignore or exclude modules, which is fine when the project is young - but as the project grows managing which dependencies need to be included where is going to become very cumbersome.

                  A similar Q&A here I think has the same essence of what I'm trying to ask, but to me, it isn't quite clear. It also references gulp-browserify which has since been blacklisted.

                  In my diagram, I can see that I have three Browserify entry points, but my lack of Gulp/Node/Browserify experience means I'm struggling to wrap my head around how I can try to achieve what I want to.

                  I'm happy to do the work to try and piece it together, as I already have been trying - however project managers are breathing down my neck so I'm having to hack together a temporary "solution" until I can implement something a little more automated and robust.

                  Thanks in advance.

                  Edit

                  It seems from Browserify's plugin documentation that this might be able to be achieved by using factor-bundle which substack pointed out to me; however again due to my lack of Node/Browserify/Gulp experience I am struggling to pull all the pieces together.

                  Related Questions

                  • How can I use factor-bundle with browserify programmatically?

                  解決方案

                  Figured it out, sharing the learns:

                  Code example:

                  var gulp = require('gulp'),
                      source = require('vinyl-source-stream'),
                      browserify = require('browserify'),
                      factor = require('factor-bundle');
                  
                  gulp.task('browserify', function(){
                  
                      return browserify({
                          entries: ['blog.js', 'page.js']
                      })
                      .plugin(factor, {
                          // File output order must match entry order
                          o: ['bundle/blog.js', 'bundle/page.js']
                      })
                      .bundle({
                          debug: true
                      })
                      .pipe(source('common.js'))
                      .pipe(gulp.dest('bundle/'));
                  
                  });
                  

                  The key difference between this output and the diagram, is that the common.js file is automatically generated based on common depenedencies between blog.js and page.js. This is described in the factor-bundle documentation.

                  Notes:

                  • I found that Node would throw an error if the output files didn't already exist. I'm unsure why as I would have assumed that factor-bundle would simply write a stream to the outputting file regardless of whether it was there or not. As a workaround, after 'cleaning' the output directory, I simply created 'placeholder' files to keep it happy.

                  • I haven't figured out how to access the factor-bundle stream event when using it as a browserify plugin (it may not even be possible), so any further work on the output files (such as uglifying etc) would likely need to be done somewhere else in the pipeline, possibly with another browserify plugin, or even after the fact.

                  這篇關(guān)于使用 Browserify 和 Gulp 使用共享的公共庫(kù)創(chuàng)建單獨(dú)的 JavaScript 包的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

                    <tfoot id='hzNIo'></tfoot>
                      <legend id='hzNIo'><style id='hzNIo'><dir id='hzNIo'><q id='hzNIo'></q></dir></style></legend>

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

                            <tbody id='hzNIo'></tbody>

                            主站蜘蛛池模板: 全自动翻转振荡器-浸出式水平振荡器厂家-土壤干燥箱价格-常州普天仪器 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 广东之窗网| 粉末包装机-给袋式包装机-全自动包装机-颗粒-液体-食品-酱腌菜包装机生产线【润立机械】 | 北京发电机出租_发电机租赁_北京发电机维修 - 河北腾伦发电机出租 | 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 披萨石_披萨盘_电器家电隔热绵加工定制_佛山市南海区西樵南方综合保温材料厂 | 胶原检测试剂盒,弹性蛋白检测试剂盒,类克ELISA试剂盒,阿达木单抗ELISA试剂盒-北京群晓科苑生物技术有限公司 | 食品无尘净化车间,食品罐装净化车间,净化车间配套风淋室-青岛旭恒洁净技术有限公司 | 上海风淋室_上海风淋室厂家_上海风淋室价格_上海伯淋 | 数显水浴恒温振荡器-分液漏斗萃取振荡器-常州市凯航仪器有限公司 | 工作服定制,工作服定做,工作服厂家-卡珀职业服装(苏州)有限公司 | 机构创新组合设计实验台_液压实验台_气动实训台-戴育教仪厂 | 耐力板-PC阳光板-PC板-PC耐力板 - 嘉兴赢创实业有限公司 | 长沙发电机-湖南发电机-柴油发电机供应厂家-长沙明邦智能科技 | 防水套管厂家-柔性防水套管-不锈钢|刚性防水套管-天翔管道 | 考勤系统_人事考勤管理系统_本地部署BS考勤系统_考勤软件_天时考勤管理专家 | 南京蜂窝纸箱_南京木托盘_南京纸托盘-南京博恒包装有限公司 | 空压机网_《压缩机》杂志 | 北京网站建设|北京网站开发|北京网站设计|高端做网站公司 | 北京自然绿环境科技发展有限公司专业生产【洗车机_加油站洗车机-全自动洗车机】 | 闭端端子|弹簧螺式接线头|防水接线头|插线式接线头|端子台|电源线扣+护线套|印刷电路板型端子台|金笔电子代理商-上海拓胜电气有限公司 | 等离子空气净化器_医用空气消毒机_空气净化消毒机_中央家用新风系统厂家_利安达官网 | 北京办公室装修,办公室设计,写字楼装修-北京金视觉装饰工程公司 北京成考网-北京成人高考网 | 行星齿轮减速机,减速机厂家,山东减速机-淄博兴江机械制造 | 税筹星_灵活用工平台_企业财务顾问_财税法薪综合服务平台 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 压装机-卧式轴承轮轴数控伺服压装机厂家[铭泽机械] | 生态板-实木生态板-生态板厂家-源木原作生态板品牌-深圳市方舟木业有限公司 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | 祝融环境-地源热泵多恒系统高新技术企业,舒适生活环境缔造者! | 牛皮纸|牛卡纸|进口牛皮纸|食品级牛皮纸|牛皮纸厂家-伽立实业 | 复盛空压机配件-空气压缩机-复盛空压机(华北)总代理 | 乐泰胶水_loctite_乐泰胶_汉高乐泰授权(中国)总代理-鑫华良供应链 | 南京雕塑制作厂家-不锈钢雕塑制作-玻璃钢雕塑制作-先登雕塑厂 | 深圳高新投三江工业消防解决方案提供厂家_服务商_园区智慧消防_储能消防解决方案服务商_高新投三江 | 大型冰雕-景区冰雕展制作公司,3D创意设计源头厂家-[赛北冰雕] | 臻知网大型互动问答社区-你的问题将在这里得到解答!-无锡据风网络科技有限公司 | 厦门网站建设_厦门网站设计_小程序开发_网站制作公司【麦格科技】 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 |