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

  • <small id='gWKXA'></small><noframes id='gWKXA'>

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

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

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

        <tfoot id='gWKXA'></tfoot>
      1. 從 gulp 中使用 browserify 時如何向瀏覽器公開“要

        How to expose #39;require#39; to the browser when using browserify from within gulp?(從 gulp 中使用 browserify 時如何向瀏覽器公開“要求?)
        <tfoot id='syPx8'></tfoot><legend id='syPx8'><style id='syPx8'><dir id='syPx8'><q id='syPx8'></q></dir></style></legend>

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

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

            <i id='syPx8'><tr id='syPx8'><dt id='syPx8'><q id='syPx8'><span id='syPx8'><b id='syPx8'><form id='syPx8'><ins id='syPx8'></ins><ul id='syPx8'></ul><sub id='syPx8'></sub></form><legend id='syPx8'></legend><bdo id='syPx8'><pre id='syPx8'><center id='syPx8'></center></pre></bdo></b><th id='syPx8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='syPx8'><tfoot id='syPx8'></tfoot><dl id='syPx8'><fieldset id='syPx8'></fieldset></dl></div>
                <tbody id='syPx8'></tbody>
                • 本文介紹了從 gulp 中使用 browserify 時如何向瀏覽器公開“要求"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  當我有一個看起來像這樣的文件 x.js 時:

                  When I have a file x.js that looks like this:

                  x.js

                  module.exports = function (n) { return n * 111 }
                  

                  然后我像這樣從命令行運行 browserify:

                  and I run browserify from the command line like so:

                  browserify -r ./x.js > bundle.js
                  

                  我得到一個看起來像這樣的輸出文件(大致):

                  I get an output file that looks like this (roughly):

                  require=(function e(t,n,r){function ......
                  ./App.jsx":[function(require,module,exports){
                  module.exports=require('0+DPR/');
                  },{}]},{},[])
                  

                  然后在我的瀏覽器代碼中我可以這樣做:

                  Then in my browser code I can do this:

                  <html>
                    <head>
                      <title>React server rendering example</title>
                      <script src="static/bundle.js"></script>
                    </head>
                    <body>
                      Welcome to the React server rendering example. Here is a server-rendered React component:
                      <div id="53a442ff8b39d"></div><script>
                      var x = require('./x.js');
                      console.log(x(3))
                  </script>  </body>
                  </html>
                  

                  我其實有兩個問題:

                  1) 這在瀏覽器中不太有效我收到錯誤:未捕獲的錯誤:找不到模塊'./x.js'".為什么會這樣?

                  1) This doesn't quite work in the browser I get the error: "Uncaught Error: Cannot find module './x.js'". Why is that happening?

                  2) 我實際上想使用乙烯基源流在 gulp 中運行它.我試過在我的 gulpfile 中做這樣的事情,但它不起作用.有任何想法嗎?我收到錯誤未定義要求"

                  2) I actually want to run this in gulp using vinyl-source-stream. I've tried doing something like this in my gulpfile but it doesn't work. Any ideas? I get the error 'require is not defined'

                  var   gulp = require('gulp'),
                    browserify = require('browserify'),
                    source = require('vinyl-source-stream');
                  
                  var b = browserify({
                      entries: ['./x.js'],
                    });
                     b.bundle({debug: false})
                     .pipe(source('bundle.js'))
                     .pipe(gulp.dest('./build'));
                  

                  推薦答案

                  更新:您可以在 -r 開關(guān)中引用別名

                  Update: You can reference an alias in your -r switch

                  試試:browserify -r ./x.js:my-module >bundle.js

                  在你的頁面中:var x = require('my-module');

                  注意:如果您在 fsthrough 等節(jié)點模塊上使用 -r 開關(guān),則不需要為這些模塊設置別名,因為它們通常有名稱在他們的 package.json 文件中.

                  NOTE: if you used an -r switch on a node module like fs or through, you don't need an alias for these because they usually have a name in their package.json file.

                  參見node-browserify -- 外部要求 了解更多信息.

                  See node-browserify -- external requires for more info.

                  如果你打算像這樣(使用 -r 開關(guān))捆綁你的 x.js,有幾個選項

                  If you are going to bundle your x.js like that (with -r switch) there are a couple of options

                  1) 將腳本放入您的 html 頁面并單獨捆綁.

                  1) Take the script in your html page and bundle it separately.

                        創(chuàng)建一個 ma??in.js 文件并將你的 JS 放入其中.

                        Create a main.js file and put your JS in it.

                        使用browserify -x ./x.js >main.js

                        Use browserify -x ./x.js > main.js

                        通過使用 -x 開關(guān),Browserify 會將您的 bundle.js 作為依賴項鏈接.

                        By using the -x switch, Browserify will link your bundle.js in as a dependancy.

                        然后在你的頁面中引用這兩個JS文件.

                        Then reference both JS files in your page.

                  2) 使用 Browserify 生成的名稱.

                  2) Use name generated by Browserify.

                        var x = require('0+DPR/');

                        var x = require('0+DPR/');

                        請參閱上面的更新以創(chuàng)建別名.

                        See Update above to create an alias.

                  下面是很好的資源,因為您希望通過 Gulp 走得更遠

                  Good resource below since you are looking to go further with Gulp

                  • Browserify - 將 Nodejs 模塊帶到瀏覽器

                  更多 Gulp + Browserify(使用 Watchify 以及 livereload)查看 Viget 上的博客文章

                  For more Gulp + Browserify (uses Watchify as well for livereload) Check out blog post on Viget

                  • Gulp + Browserify:所有帖子

                  這篇關(guān)于從 gulp 中使用 browserify 時如何向瀏覽器公開“要求"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?(是否可以將標志傳遞給 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 崩潰)
                • <tfoot id='9RdAq'></tfoot>

                    <tbody id='9RdAq'></tbody>
                  <legend id='9RdAq'><style id='9RdAq'><dir id='9RdAq'><q id='9RdAq'></q></dir></style></legend>

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

                      <i id='9RdAq'><tr id='9RdAq'><dt id='9RdAq'><q id='9RdAq'><span id='9RdAq'><b id='9RdAq'><form id='9RdAq'><ins id='9RdAq'></ins><ul id='9RdAq'></ul><sub id='9RdAq'></sub></form><legend id='9RdAq'></legend><bdo id='9RdAq'><pre id='9RdAq'><center id='9RdAq'></center></pre></bdo></b><th id='9RdAq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9RdAq'><tfoot id='9RdAq'></tfoot><dl id='9RdAq'><fieldset id='9RdAq'></fieldset></dl></div>
                        <bdo id='9RdAq'></bdo><ul id='9RdAq'></ul>
                          • 主站蜘蛛池模板: 黄色免费av| 操夜夜| 久久av一区二区三区 | 欧美一级电影免费观看 | 日本不卡一区二区三区在线观看 | 成人自拍视频网站 | 我爱操| 亚洲日本一区二区 | 久久久www成人免费精品张筱雨 | 91视频在线 | 国产精品久久久99 | 精品国产精品国产偷麻豆 | 91se在线 | 麻豆久久| 自拍 亚洲 欧美 老师 丝袜 | 成人精品一区二区户外勾搭野战 | 免费观看a级毛片在线播放 黄网站免费入口 | 午夜精品久久久久久久久久久久 | 欧美精品区 | 一区二区三区免费观看 | av在线一区二区 | 亚洲国产一区在线 | 青青草网 | 久久精品99| 国产aa | 欧美精品三区 | 综合色播 | 久久国产区 | www.一区二区三区 | 成人影视网址 | 欧美精品网站 | 国产毛片久久久久久久久春天 | 欧美视频一区二区三区 | 人成久久 | 人人做人人澡人人爽欧美 | 欧美激情欧美激情在线五月 | 一区二区三区四区国产 | 亚洲欧美国产精品一区二区 | 香蕉婷婷| 一区中文字幕 | 色综合99 |