Skip to content

Instantly share code, notes, and snippets.

@plemarquand
Created April 21, 2014 19:11
Show Gist options
  • Save plemarquand/11153140 to your computer and use it in GitHub Desktop.
Save plemarquand/11153140 to your computer and use it in GitHub Desktop.
Gruntfile: Relative sourcemap paths with grunt-browserify and mold-source-map
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();
}
}
}
});
};
@zrubinrattet
Copy link

bundleOptions is no longer used. Move all option in browserifyOptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment