grunt-contrib-uglify
grunt-contrib-uglify copied to clipboard
Allow to customize the “sources” field in the sourcemaps.
Currently the sources
field in sourcemaps is always relative to the sources. In my case it looks somewhat ugly:
../../../../src/main/webapp/home/scripts/home.js
I’m including the sources with sourcesContent
and not serving the actual sources (and if I were serving them, it wouldn’t be at that path...).
Is there an option to tweak that relative path? uglify.js mentions -p
/--prefix
, but as far as I can see it’s not available from this plugin. I also tried sourceMapRoot
, but it did nothing.
My base setup is like this:
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true,
compress: true,
mangle: true
},
build: {
files: [{
/* Minify all but vendor scripts */
expand: true,
cwd: 'src/main/webapp/home',
src: ['scripts/**/*.js', '!scripts/vendor/**'],
dest: 'target/grunt/home'
}]
}
}
This feature might be useful yeah. A workaround right now is to write a simple task that does something like:
var updateMap = JSON.parse(fs.readFileSync(SOURCEMAP_PATH));
updateMap.sources = ['some-path.js'];
fs.writeFileSync(SOURCEMAP_PATH, JSON.stringify(updateMap));
+1
+1
+1