How to obfuscate ionic build to publish?


Hello mates,

I’m going to publish my first app to the google store and I need some advice or help to how I can obfuscate, shrink, minify, etc, my Ionic 3 application when I generate the build to publish.

I found some articles like this one:


So, I believe that have someone here that already did this before. Help me! :stuck_out_tongue:

Best regards


Building with --prod automatically runs uglify.js.


What if there are css and js files under the assets folder?
The --prod build does not appear to have any impact on these files, even if they need to be optimized.


I think putting scripts under the assets folder is a mistake. All code that can be managed by webpack should be. It’s not just minification; there’s also dead code elimination.


the ionic conference app has a .json file (ok, not a “script” proper) under the “assets” folder.

How would one go about optimizing this file - e.g., minification - in ionic 3?


I don’t see any point in trying to do that. If you change the property names, the data will no longer be usable in its intended form. Compressing it would be theoretically possible, but I don’t think it would be relevant as app binaries are zipped anyway.


No point in minification if the file is large and minifying can significantly reduce the file size?


Then do it manually or change to configuration so that it also minifies that one file.


Techniques used in JavaScript minification don’t apply for JSON assets. Think about it from an information theory standpoint: every property name and value in a JSON file conveys as much information as that name or value’s string representation. There is no way you can shrink a JSON file (except for whitespace compression) while preserving the requirement that JSON.parse() will return a functionally identical object as it would on the original version.


@Sujan12 - Can you please elaborate on where to get started with “changes to configuration” for a task like this?


No idea. It is a not very good idea with minimal payoff as @rapropos mentioned.
Probably in ionic app-scripts somehow.


So I’m here with the same question. By reading what you guys have responded --prod runs uglify and minify automatically, but what about obfuscating? Is it necessary? I found an npm package for ionic for what I need, but I want to make sure I even need it.

Thanks in advance.