I'm developing a library in JS and I want to preserve 'debugger' keyword after using grunt-contrib-uglify because is intentional usage, but default behavior (obviously) is delete all debuggers.
My grunt file:
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
CrackerTrapProductionMinJS: {
options:{
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n',
drop_console: true,
mangle: {
reserved: ['debugger']
}
},
files: {
'./build/cracker-trap.min.js': './build/cracker-trap.ob.js'
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};
And the method that I want to preserve the debugger keyword to validate if user has developer tools opened:
function timeValidation() {
var startTime = new Date();
debugger;
var endTime = new Date();
return endTime - startTime > 100;
}
Complete code in: https://github.com/bioverflow/cracker-trap