簡體   English   中英

如何從構建中排除.js.map?

[英]How to exclude .js.map from build?

我需要從構建文件結尾/包含中排除

.js.map  

.js.uncompressed.js

我正在嘗試使用一些regex沒有成功

        ignore: function(t) {
            return /\.js.map$/.test(t)
        },
        miniExclude: function(t) {
            return /\.js.map$/.test(t)
        }

我正在使用DOJO 1.10。

我在這里做錯了什么?


var profile = function() {
    return {
        basePath: "../",
        releaseDir: "dist",
        releaseName: "build",
        optimize: "closure",
        action: "release",
        layerOptimize: "closure",
        copyTests: !1,
        stripConsole: "all",
        version: "ntv-0.0.0",
        cssOptimize: "comments",
        mini: !0,
        staticHasFeatures: {
            "dojo-trace-api": !1,
            "dojo-log-api": !1,
            "dojo-publish-privates": !1,
            "dojo-sync-loader": !1,
            "dojo-xhr-factory": !1,
            "dojo-test-sniff": !1
        },
        resourceTags: {
            amd: function(t) {
                return /\.js$/.test(t)
            },
            ignore: function(t) {
                return /\.js.map$/.test(t)
            },
            miniExclude: function(t) {
                return /\.js.map$/.test(t)
            }
        },
        packages: [{
            name: "dojo",
            location: "dojo"
        }, {
            name: "test",
            location: "test"
        }],
        layers: {
            "dojo/dojo": {
                include: ["dojo/dojo"],
                customBase: !0,
                boot: !0
            },
            "test/c": {
                include: ["test/c/c"],
                customBase: !0,
                boot: !1
            },
            "test/b": {
                include: ["test/b/b"],
                customBase: !0,
                boot: !1
            },
            "test/a": {
                include: ["test/a/a"],
                customBase: !0,
                boot: !1
            }
        }
    }
}();

首先,問題中使用的“排除”一詞不太准確。 這些是構建系統生成文件-它們不是源中首先要排除的文件。

如果您不希望構建生成源地圖,請在構建配置文件中設置useSourceMaps: false

至於*.uncompressed.js文件,此構建會為其最小化的任何模塊或層自動生成這些文件。 如果您確實不希望它們出現在構建輸出中,則需要在注釋之后使用諸如frank這樣的命令將其刪除。

通常都包含這兩個文件的原因是為了幫助調試已構建的應用程序。 在正常使用期間,這些文件都不會被瀏覽器下載; 僅開發人員工具會要求它們。

"asd.js.uncompressed.js".match(/.{1,}\.(js\.map|js\.uncompressed\.js)$/g) //match
"khaslkda.js.map".match(/.{1,}\.(js\.map|js\.uncompressed\.js)$/g) //match
"khaslkda.map".match(/.{1,}\.(js\.map|js\.uncompressed\.js)$/g) // no match
"khaslkda.map.js".match(/.{1,}\.(js\.map|js\.uncompressed\.js)$/g) //no match

我不太了解道場。 但是這個正則表達式可以幫助您嗎?

編輯:我用火柴..但它也應該與測試一起工作。 就這樣吧

/.{1,}\.(js\.map|js\.uncompressed\.js)$/g.test("as-_d.js.uncompressed.js") //true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM