rossmartin / cordova-uglify

Cordova hook that allows you to uglify or minify your apps JavaScript and CSS.
MIT License
116 stars 46 forks source link

New to uglify, a few questions please. #44

Closed rolinger closed 5 years ago

rolinger commented 5 years ago

Hello,

I have never used uglify or minify with any of my programming before, never quite had a business need to do so, but now I do. A few questions if you will. I have created an ionic v1 app (a while ago) for both android and ios - i will be doing a massive overhaul to move from v1 to v4 in the coming months - but just not there yet. I develop for Android on a windows 7 system and iOS on Mac (obviously).

If I install this plugin:

  1. Can I install it in such a way to only uglify/minify my code for when its time to release the app to the stores? I want to be able to still use console and see my html/css when I use chrome/safari inspector tools while developing. I have read about the --release option, but does that mean when using the option it DOES uglify at that moment...or does installing it auto uglify everytime unless you specify --release at which time it won't uglify.

  2. On iOS, I compile everything from command line cordova build myApp and then run it from Xcode to the simulator or to a real device, if uglified (pre-release) will Xcode still be able to see the readable code from the project www root or is it reading code from the platform/www? (for Android I do everything via CLI and only use Studio for SDK Package Manager)

  3. I read the image compression is removed and that HTML is not yet being compressed, is this still the case for both?

  4. I use a few local json files in platform/assets folders, mainly app initialization stuff. Will those files get uglified/minified too?

  5. Are there any additional things I need to be aware of considering my project is on the older ionic v1 platform?

  6. This plugin does everything during the build/prepare process, are there any methods you are aware of that will allow me to ugilify/minify json files that are stored to local assets while the app is running? My app checks for updated json files from central servers for various services and stores them locally for future use, is there anyway I can minify/uglify those json files while the app is running...so it stores them uglified?

rossmartin commented 5 years ago

You can use this hook with an ionic v1 app but when you update to v4 this hook will no longer be needed. Their CLI provides a way to minify/uglify your code (see here https://ionicframework.com/docs/developer-resources/app-scripts/)

  1. Yes. By default it will only uglify when the --release option is provided. There is also the alwaysRun option in the uglify-config.json.
  2. When you run the app on a device it is always using the code that is within platforms/${platform}/www. It never uses what is on the www root for a packaged app (debug or release).
  3. Yes
  4. No
  5. No
  6. This hook doesn't do anything at runtime. One quick thought I have for your json files is to just serialize them to JSON without any indentation (no "prettifying"). So you could just do JSON.stringify(obj) if the JSON is "prettified". I don't think you'd want to uglify or obfuscate the json files. There is probably a library out there to do that if you really need it.

Thanks