I'm using grunt-bbb for a JavaScript project I'm working on. I'd love to use conditional compilation using grunt's support for UglifyJS, but I cannot seem to get it to work. I'm trying to pass a defines
option to uglify task, but it doesn't seem to be working.
My grunt.js file looks like:
module.exports = function (grunt) {
grunt.initConfig({
// ... config options ...
uglify: {
"mangle": {
"defines": {"DEBUG": false}
}
},
// ... more configs ...
});
// ... custom tasks ...
grunt.registerTask("release", "default min mincss");
};
I've tried to add an except
property to the mangle
object as well, and that doesn't seem to work either (it still mangles the file...) UglifyJS is obviously being run, but it doesn't seem like it's getting the options passed in. I've dug through the code as well and when I console.log(grunt.config('uglify'));
I get
{ mangle: { defines: { DEBUG: false } } }
which looks correct to me...
Any thoughts???
I submitted an issue to Grunt and aparently the problem is inside Uglify (the way the defines
parameter is actually handled contradicts the docs).
This follwing code works:
uglify: {
mangle: {
defines: {
DEBUG: ['name', 'true']
}
}
}