How to exclude .js.map from build?

2k Views Asked by At

I need to exclude from my build file ending/containing

.js.map  

and

.js.uncompressed.js

I am trying using some regex with no success

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

I am using DOJO 1.10.

What am I doing wrong here?


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
            }
        }
    }
}();
2

There are 2 best solutions below

0
Ken Franqueiro On BEST ANSWER

First of all, the word "exclude" used in the question isn't quite accurate. These are files that are generated by the build system - they're not files existing in the source to be excluded in the first place.

If you don't want the build to generate source maps, set useSourceMaps: false in your build profile.

As for the *.uncompressed.js files, the build generates these automatically for any module or layer that it minifies. If you really don't want them in the build output, you'll need to remove them afterwards with a command like frank suggested in the comments.

The reason both of these files are included ordinarily is to assist in debugging of built applications. Neither of these files will be downloaded by a browser during normal use; they will only be requested by developer tools.

0
springbo On
"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

I don't really know dojo. But this regex might help you?

edit: I used match.. but it should work with test as well. Just do like this

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