久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='r9NZ9'></bdo><ul id='r9NZ9'></ul>

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

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

        使用 Gulp 使 browserify 模塊外部化

        Make browserify modules external with Gulp(使用 Gulp 使 browserify 模塊外部化)
            • <tfoot id='pWBR4'></tfoot>
            • <small id='pWBR4'></small><noframes id='pWBR4'>

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

                  <bdo id='pWBR4'></bdo><ul id='pWBR4'></ul>
                • 本文介紹了使用 Gulp 使 browserify 模塊外部化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有一個庫 lib.js 我想從 lib/a.jslib/b.js 創建并能夠使用 var a = require('lib/a.js'); 從腳本 client.js 使用它,并且當我只包含已編譯的lib.js 庫在 client.js 之前(因此,lib.js 必須聲明一個知道的 require 函數關于 lib/a.js)

                  I have a library lib.js that I want to create from lib/a.js and lib/b.js and to be able to use it from a script client.js using var a = require('lib/a.js'); and that it works when I just include the compiled lib.js library before client.js (therefore, lib.js has to declare a require function that knows about lib/a.js)

                  我想我必須使用 externalalias 但我不確定什么是正確的方法

                  I guess I have to use external and alias but I am not sure what is the proper way to do it

                  另外,是否有可能有一個 Gulp 文件為我的庫中的文件夾自動創建所有別名?例如.為 lib/ 目錄中的所有文件創建別名?

                  Also, is it possible to have a Gulp file that creates all the alias automatically for the folders in my library? eg. creates an alias for all the files in the lib/ dir?

                  推薦答案

                  這里有幾個 gulp 任務可以幫助你分別構建通用的 lib.js 和 client.js 包.

                  Here are a couple of gulp tasks that would help to build your common lib.js and the client.js bundles separately.

                  請注意,捆綁 lib.js 時必須將 browserify 告知 b.require() lib/*.js,并且必須告知 b.external() 捆綁客戶端時將單獨加載的庫.js

                  Note that you have to tell browserify to b.require() lib/*.js when bundling lib.js, and you have to tell it to b.external() the libraries that will be loaded separately when bundling client.js

                  var path = require('path');
                  var gulp = require('gulp');
                  var browserify = require('browserify');
                  var concat = require('gulp-concat');
                  var transform = require('vinyl-transform');
                  
                  gulp.task('build-lib', function () {
                  
                    // use `vinyl-transform` to wrap around the regular ReadableStream returned by b.bundle();
                    // so that we can use it down a vinyl pipeline as a vinyl file object.
                    // `vinyl-transform` takes care of creating both streaming and buffered vinyl file objects.
                    var browserified = transform(function(filename) {
                  
                      // basename, for eg: 'a.js'
                      var basename = path.basename(filename);
                  
                      // define the exposed name that your client.js would use to require();
                      // for eg: require('lib/a.js'); // -> exposed name should be 'lib/a.js'
                      var expose = 'lib/' + basename;
                  
                      return browserify(filename)
                        .require(filename, { expose: expose})
                        .bundle();
                    });
                  
                    return gulp.src(['./lib/*.js'])
                      .pipe(browserified)
                      .pipe(concat('lib.js'))
                      .pipe(gulp.dest('./dist'));
                  });
                  
                  gulp.task('build-client', function () {
                  
                    var browserified = transform(function(filename) {
                      // filename = './client.js'
                  
                      // let browserify know that lib/a.js and and lib/b.js are external files
                      // and will be loaded externally (in your case, by loading the bundled lib.js 
                      // for eg: <script src='dist/lib.js'>)
                      return browserify(filename)
                        .external('lib/a.js')
                        .external('lib/b.js')
                        .bundle();
                    });
                  
                    return gulp.src(['./client.js'])
                      .pipe(browserified)
                      .pipe(gulp.dest('./dist'));
                  });
                  
                  gulp.task('default', ['build-lib', 'build-client']);
                  

                  這篇關于使用 Gulp 使 browserify 模塊外部化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)

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

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

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

                      <bdo id='zV6k2'></bdo><ul id='zV6k2'></ul>

                            <tfoot id='zV6k2'></tfoot>
                          1. 主站蜘蛛池模板: 亚洲欧洲小视频 | 成人a在线观看 | 一区二区三区亚洲 | 国产激情视频 | 一区二区三区免费观看 | 中文字幕一区二区三区乱码在线 | 亚洲精品福利视频 | 免费久久精品 | 亚洲成网站 | 国产91丝袜在线播放 | 亚洲欧美在线一区 | 好姑娘影视在线观看高清 | 在线日韩视频 | 精品一区在线 | 99re6热在线精品视频播放 | 中文字幕精品一区二区三区精品 | 亚洲一区二区三区免费观看 | 日韩中文在线视频 | 日韩国产在线观看 | 毛片国产| 国产午夜精品一区二区三区嫩草 | 国产精品久久久久久久久久 | 久久亚 | 久久久精品视频一区二区三区 | 亚洲精品久 | 久久国 | www.色综合 | 四虎影院在线免费观看 | 国产伦精品一区二区三区精品视频 | 91久久精品一区二区三区 | 国产精品一区二区在线 | 精品一区二区在线视频 | 久久精品色欧美aⅴ一区二区 | 伦理一区二区 | 91电影院 | 九九热视频这里只有精品 | 国产福利资源在线 | 国产成在线观看免费视频 | 成人欧美一区二区三区1314 | 热久色 | 婷婷丁香综合网 |