Change format of the Source map created from closure compiler

I have this closure-compiler task defined with following options:

'closure-compiler': {
    files: {
    },
    options: {
        externs: [],
        compilation_level: 'ADVANCED_OPTIMIZATIONS',
        language_in: 'ECMASCRIPT5_STRICT',
        create_source_map: '<%= sourceDir %>js/<%= outputName %>.min.js.map',
        output_wrapper: '%output%\n//# sourceMappingURL=<%= sourceMapURL %>js/<%= outputName %>.min.js.map'
    }
}

the sourcemap is created and it looks like this:

{
  "version":3,
  "file":"build/js/game.min.js",
  "lineCount":39,
  "mappings":"AAEA,...",
  "sources":["/src/js/utils.js","/src/js/game/Button.js",...],
  "names":[...]
}

but then the source map doesnt work, what I need is:

{
  "version":3,
  "file":"game.min.js",
  "lineCount":39,
  "mappings":"AAEA,...",
  "sources":["utils.js","game/Button.js",...],
  "names":[...]
}

what should I do to have the sourcemap created in that form?

Upvotes: 1

Views: 86

Answers (1)

Chad Killingsworth
Chad Killingsworth

Reputation: 14411

For Grunt, there are many options for sourcemaps that have to be handled as a separate build step. It lacks the power of the gulp-sourcemaps plugin and so either each tool has to handle every conceivable option for generating a sourcemap or another tool must be used.

Post processing a sourcemap in this fashion isn't too difficult as sourcemaps are JSON data.

grunt-sourcemap-localize looks to do exactly what you are wanting.

Upvotes: 2

Related Questions