Created
April 21, 2014 19:11
-
-
Save plemarquand/11153140 to your computer and use it in GitHub Desktop.
Gruntfile: Relative sourcemap paths with grunt-browserify and mold-source-map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// load only required grunt tasks as tasks are run | |
require('jit-grunt')(grunt); | |
// Project configuration. | |
grunt.initConfig({ | |
browserify : { | |
files : { | |
'test/browserified_unit_tests.js' : 'test/spec/**.js' | |
}, | |
options : { | |
bundleOptions : { | |
// Embed source map for tests | |
debug : true | |
}, | |
// Convert absolute sourcemap filepaths to relative ones using mold-source-map. | |
postBundleCB: function(err, src, cb) { | |
var through = require('through'); | |
var stream = through().pause().queue(src).end(); | |
var buffer = ''; | |
stream.pipe(require('mold-source-map').transformSourcesRelativeTo(__dirname)).pipe(through(function(chunk) { | |
buffer += chunk.toString(); | |
}, function() { | |
cb(err, buffer); | |
})); | |
stream.resume(); | |
} | |
} | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bundleOptions is no longer used. Move all option in browserifyOptions.