Reputation: 1474
I'm new to Grunt, trying to get grunt-contrib-uglify
to work and it appears to be working well, however it keeps removing, console.log('hello world')
every time it runs.
I see a lot of mentions on how to get Uglify to remove console.log
but nothing on actually keeping, which I assumed was the default.
Here's my uglify
task:
uglify:{
options: {
compress: {
unused: false,
drop_console: false
}
},
my_target: {
files: {
'_/js/script.js' : ['_/components/js/*.js']
} //files
} //my_target
}, //uglify
Here's my JavaScript file:
function test(){
return 'hello there again once more';
console.log('test');
}
It's keeping the return
line, but not console.log
.
Upvotes: 1
Views: 581
Reputation: 1497
function test(){
return 'hello there again once more';
console.log('test'); <- this is at wrong place
}
it should be before return
function test(){
console.log('test'); <- this SHOULD WORK
return 'hello there again once more';
}
Upvotes: 1
Reputation: 9273
Are you sure it's actually removing it? Is it just that you aren't seeing the log in the console?
The console.log
statement is after the return
statement, so is never going to be executed. The function has stopped at that point. The try moving console.log
to before the return
statement.
Upvotes: 1