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

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

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

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

    1. <tfoot id='ubdaI'></tfoot>
      <legend id='ubdaI'><style id='ubdaI'><dir id='ubdaI'><q id='ubdaI'></q></dir></style></legend>

      使用 webpack 和 gulp 用于縮小、轉(zhuǎn)譯 ES6 代碼的外部

      External source maps for minified, transpiled ES6 code with webpack and gulp(使用 webpack 和 gulp 用于縮小、轉(zhuǎn)譯 ES6 代碼的外部源映射)
        <tbody id='2YtRz'></tbody>
      <i id='2YtRz'><tr id='2YtRz'><dt id='2YtRz'><q id='2YtRz'><span id='2YtRz'><b id='2YtRz'><form id='2YtRz'><ins id='2YtRz'></ins><ul id='2YtRz'></ul><sub id='2YtRz'></sub></form><legend id='2YtRz'></legend><bdo id='2YtRz'><pre id='2YtRz'><center id='2YtRz'></center></pre></bdo></b><th id='2YtRz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2YtRz'><tfoot id='2YtRz'></tfoot><dl id='2YtRz'><fieldset id='2YtRz'></fieldset></dl></div>

              <bdo id='2YtRz'></bdo><ul id='2YtRz'></ul>

              <small id='2YtRz'></small><noframes id='2YtRz'>

              <tfoot id='2YtRz'></tfoot>
              • <legend id='2YtRz'><style id='2YtRz'><dir id='2YtRz'><q id='2YtRz'></q></dir></style></legend>
                本文介紹了使用 webpack 和 gulp 用于縮小、轉(zhuǎn)譯 ES6 代碼的外部源映射的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時送ChatGPT賬號..

                我正在編寫 ES6 代碼并使用 Babel 將其轉(zhuǎn)換為 ES5,然后使用 Uglify 進行縮小.全部通過 gulp 使用 webpack 運行.我想使用外部源映射(以使文件盡可能小).

                I'm writing ES6 code and transpile it to ES5 with Babel, then minify with Uglify. All run with webpack via gulp. I would like to use external source maps (to keep filesize as small as possible).

                gulp 任務(wù)非常基礎(chǔ)——所有時髦的東西都在 webpack 配置中:

                The gulp task is pretty basic - all the funky stuff is in the webpack config:

                var gulp = require("gulp");
                var webpack = require("gulp-webpack");
                
                gulp.task("js:es6", function  () {
                  return gulp.src(path.join(__dirname, "PTH", "TO", "SRC", "index.js"))
                  .pipe(webpack(require("./webpack.config.js")))
                  .pipe(gulp.dest(path.join(__dirname, "PTH", "TO", "DEST")));
                });
                

                webpack.config.js:

                webpack.config.js:

                var path = require("path");
                var webpack = require("webpack");
                
                module.exports = {
                  output: {
                    filename: "main.js",
                    sourceMapFilename: "main.js.map"
                  },
                  devtool: "#inline-source-map",
                  module: {
                    loaders: [
                        { test: path.join(__dirname, "PTH", "TO", "SRC"),
                          loader: "babel-loader" }
                    ]
                  },
                  plugins: [
                    new webpack.optimize.UglifyJsPlugin({
                      compress: {
                        warnings: false
                      },
                      output: {
                        comments: false,
                        semicolons: true
                      },
                      sourceMap: true
                    })
                  ]
                };
                

                上述方法有效,它創(chuàng)建了有效的源映射 - 但它們是內(nèi)聯(lián)的.

                The above works and it creates working source maps - but they are inline.

                如果我將 webpack.config.js 更改為 devtool: "#source-map",則源映射將創(chuàng)建為單獨的文件(使用 sourceMapFilename作為文件名).但它不可用 - Chrome 開發(fā)工具似乎無法理解它.如果我刪除 webpack.optimize.UglifyJsPlugin 源映射是可用的 - 但代碼沒有被縮小.因此源映射適用于兩個單獨的步驟,但不適用于按順序運行.

                If I change webpack.config.js so that it says devtool: "#source-map", the source map is created as a separate file (using sourceMapFilename as filename). But it isn't usable - Chrome dev tools doesn't seem to understand it. If I remove the webpack.optimize.UglifyJsPlugin the source map is usable - but the code is not minified. So source map works for the two individual steps, but not when they are run in sequence.

                我懷疑 uglify 步驟忽略了上一個轉(zhuǎn)譯器步驟中的外部源映射,所以它生成的源映射是基于流的,當(dāng)然在 gulp 之外不存在.因此無法使用源映射.

                I suspect the uglify step ignores the external sourcemap from the previous transpiler step, so the sourcemap it generates is based on the stream, which of course doesn't exist outside of gulp. Hence the unusable source map.

                我對 webpack 還很陌生,所以我可能會遺漏一些明顯的東西.

                I'm pretty new to webpack so I may be missing something obvious.

                我想要做的是類似于這個問題,但使用 webpack 而不是 browserify:Gulp + browserify + 6to5 + source maps

                What I'm trying to do is similar to this question, but with webpack instead of browserify: Gulp + browserify + 6to5 + source maps

                提前致謝.

                推薦答案

                我強烈建議將你的 webpack 配置放在 gulpfile 中,或者至少讓它成為一個函數(shù).這有一些不錯的好處,例如可以將它重用于不同的任務(wù),但有不同的選項.

                I highly recommend putting your webpack config inside the gulpfile, or at least make it a function. This has some nice benefits, such as being able to reuse it for different tasks, but with different options.

                我還建議直接使用 webpack,而不是使用 gulp-webpack(特別是如果它是你唯一要通過管道的東西).根據(jù)我的經(jīng)驗,這將給出更可預(yù)測的結(jié)果.通過以下配置,即使使用 UglifyJS,源映射對我來說也能正常工作:

                I also recommend using webpack directly instead of using gulp-webpack (especially if it's the only thing you're piping through). This will give much more predictable results, in my experience. With the following configuration, source maps work fine for me even when UglifyJS is used:

                "use strict";
                
                var path = require("path");
                var gulp = require("gulp");
                var gutil = require("gulp-util");
                var webpack = require("webpack");
                
                function buildJs (options, callback) {
                    var plugins = options.minify ? [
                        new webpack.optimize.UglifyJsPlugin({
                            compress: {
                                warnings: false,
                            },
                
                            output: {
                                comments: false,
                                semicolons: true,
                            },
                        }),
                    ] : [];
                
                    webpack({
                        entry: path.join(__dirname, "src", "index.js"),
                        bail: !options.watch,
                        watch: options.watch,
                        devtool: "source-map",
                        plugins: plugins,
                        output: {
                            path: path.join(__dirname, "dist"),
                            filename: "index.js",
                        },
                        module: {
                            loaders: [{
                                loader: "babel-loader",
                                test: /.js$/,
                                include: [
                                    path.join(__dirname, "src"),
                                ],
                            }],
                        },
                    }, function (error, stats) {
                        if ( error ) {
                            var pluginError = new gutil.PluginError("webpack", error);
                
                            if ( callback ) {
                                callback(pluginError);
                            } else {
                                gutil.log("[webpack]", pluginError);
                            }
                
                            return;
                        }
                
                        gutil.log("[webpack]", stats.toString());
                        if (callback) { callback(); }
                    });
                }
                
                gulp.task("js:es6", function (callback) {
                    buildJs({ watch: false, minify: false }, callback);
                });
                
                gulp.task("js:es6:minify", function (callback) {
                    buildJs({ watch: false, minify: true }, callback);
                });
                
                gulp.task("watch", function () {
                    buildJs({ watch: true, minify: false });
                });
                

                這篇關(guān)于使用 webpack 和 gulp 用于縮小、轉(zhuǎn)譯 ES6 代碼的外部源映射的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 崩潰)

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

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

                        • <legend id='SJ9xi'><style id='SJ9xi'><dir id='SJ9xi'><q id='SJ9xi'></q></dir></style></legend>
                            <tbody id='SJ9xi'></tbody>

                          <tfoot id='SJ9xi'></tfoot>
                          主站蜘蛛池模板: 久久91精品久久久久久9鸭 | 成年人视频在线免费观看 | 91小视频在线 | 国产精品成人国产乱一区 | 一级黄色片网站 | 精品成人av | 四虎成人免费视频 | 亚洲 欧美 日韩 精品 | 91视频亚洲| 老牛影视av一区二区在线观看 | 日韩中文电影 | www久久久| 一本大道久久a久久精二百 国产成人免费在线 | 欧美黄色性生活视频 | 国产精品一区在线观看你懂的 | 中文字幕亚洲精品 | 91免费版在线观看 | 国产成人综合在线 | 国产欧美一区二区三区在线看 | 成人在线日韩 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | 毛片a级 | 欧美一区在线视频 | 国产精品久久久久久久午夜片 | 亚洲精品天堂 | 美女黄频 | www日| 在线免费观看a级片 | 99国产精品久久久久久久 | 久久九 | 中文字幕在线一区二区三区 | 精品伊人 | 欧美激情精品久久久久久变态 | 日韩高清中文字幕 | 久久久女女女女999久久 | 亚洲 中文 欧美 日韩 在线观看 | 一级黄片一级毛片 | 国产一区亚洲 | 免费在线观看一级毛片 | 国产免费又色又爽又黄在线观看 | 精品国产99|