grunt-contrib-uglify 不断删除 console.log
grunt-contrib-uglify keeps removing console.log
我是 Grunt 的新手,试图让 grunt-contrib-uglify
正常工作,它似乎运行良好,但它一直在删除,console.log('hello world')
每次运行。
我看到很多关于如何让 Uglify 删除 console.log
但没有提到实际保留,我认为这是默认设置。
这是我的 uglify
任务:
uglify:{
options: {
compress: {
unused: false,
drop_console: false
}
},
my_target: {
files: {
'_/js/script.js' : ['_/components/js/*.js']
} //files
} //my_target
}, //uglify
这是我的 JavaScript 文件:
function test(){
return 'hello there again once more';
console.log('test');
}
它保留 return
行,但不保留 console.log
。
你确定它真的在删除它吗?只是您没有在控制台中看到日志吗?
console.log
语句是 在 return
语句之后,因此永远不会被执行。该功能已在该点停止。尝试将 console.log
移动到 return
语句之前。
function test(){
return 'hello there again once more';
console.log('test'); <- this is at wrong place
}
应该在return
之前
function test(){
console.log('test'); <- this SHOULD WORK
return 'hello there again once more';
}
我是 Grunt 的新手,试图让 grunt-contrib-uglify
正常工作,它似乎运行良好,但它一直在删除,console.log('hello world')
每次运行。
我看到很多关于如何让 Uglify 删除 console.log
但没有提到实际保留,我认为这是默认设置。
这是我的 uglify
任务:
uglify:{
options: {
compress: {
unused: false,
drop_console: false
}
},
my_target: {
files: {
'_/js/script.js' : ['_/components/js/*.js']
} //files
} //my_target
}, //uglify
这是我的 JavaScript 文件:
function test(){
return 'hello there again once more';
console.log('test');
}
它保留 return
行,但不保留 console.log
。
你确定它真的在删除它吗?只是您没有在控制台中看到日志吗?
console.log
语句是 在 return
语句之后,因此永远不会被执行。该功能已在该点停止。尝试将 console.log
移动到 return
语句之前。
function test(){
return 'hello there again once more';
console.log('test'); <- this is at wrong place
}
应该在return
之前function test(){
console.log('test'); <- this SHOULD WORK
return 'hello there again once more';
}