JakeHova
JakeHova

Reputation: 1365

Troubleshooting grunt-uglify issue

I'm using grunt to build my Angular JS project and I'm running into a weird issue that I havent run into before.

I use grunt-contrib-concat and then grunt-contrib-uglilfy to generate the code. If I use just concat, things work as expected. But when I include the uglify, I get an error in the functioning of my code that obviously wasnt there before the build process or after the concat process.

Is there a good way to troubleshoot and possibly override the "uglification" process to handle the error?

Note: The issue isn't with the running of the uglify task, the task runs completely and all files are minified/uglified successfully. The problem is that one of the pieces of functionality in the system fails after uglifying but works fine prior to that.

Upvotes: 1

Views: 418

Answers (2)

MarcoS
MarcoS

Reputation: 17711

As a general rule with this class of issues, I would try to set all grunt-contrib-uglify options to false, and then check if your app works fine again.

Then, I would set options to true, one by one, always checking the app functioning before activating the next one. So, at the end of the process, you should arrive to identify the offending option.

Then you can choose to leave if off, and go only with the others, or otherwise to deepen your investigative process, possibly understanding why that option conflicts with your code, and correcting it (or leaving that option off...).

Hope it helps...

UPDATE: Possibly @Michelem suggestion is correct; if it is not, go on with my suggested procedure...

Upvotes: 2

michelem
michelem

Reputation: 14590

You are probably mangling the files and this could lead in problems when you concatenate many files because the mangle operation change variable and function names, just use the option mangle: false on your uglify config and you should be done:

uglify: {
    options: {
        mangle: false
    }
},

Upvotes: 3

Related Questions