Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Shane_L_
Beginner
110 Views

Concatenation, minute and Uglify Ionic project and still build in XDK

Hi,

I have built an app with Ionic and XDK and it is on the App Store and Google Play store but I'd like to concate, minify and obfuscate the code.

Much searching comes up with suggestions about Grunt but I don't see how I could do this and still use the XDK to build the .ipa and .apk files

I would be greatful if someone could walk me through this a bit.

Thanks very much

Shane

Tags (2)
0 Kudos
6 Replies
John_H_Intel2
Employee
110 Views

You should be able to use them without a problem. It might be helpful to keep a copy of your code before you use them though. Once you run the process, and build, you can then revert to your saved copy so you can continue to edit your source code.

Shane_L_
Beginner
110 Views

I tried to do this using the process in this webpage

http://www.joshmorony.com/how-to-minify-an-ionic-application-for-production/

Up to the gruntfile

However when you have used XDK the config.json file is altered so ionic serve won't run, therefore gulp doesn't work the same. In fact gulp and bower aren't even recognised in this option. I'm not sure where to go from here.

I assume I could just run the grunt uglify part, however I'd like to concatenate and minify for functional reasons. I can't find any information relevant to this process with the XDK and I'm at a loss where to go further.

I'd appreciate some guidance if possible.

 

Thanks

 

Shane

PaulF_IntelCorp
Employee
110 Views

Shane -- there is no performance improvement associated with a minify or concatenation operation in an XDK (aka Cordova or PhoneGap) app because you load the files from a local filesystem, you're not loading them over a network interface off a server. However, you may wish to obfuscate for security (which might require concatenation, as well).

The XDK does not provide much help in this regard. What I have seen some people do is create two source directories in their project (the default is www, call the other one something like "prod"). Then use your obfuscation tools to process what is in the www directory and save the results of the obfuscation operation to the prod directory. Make sure that EVERYTHING in the www folder is copied to the prod folder, even those files that are not modified by the obfuscation process.

Continue to do all of your development work with the www directory. When you are ready to build, switch the XDK project source directory to point to your prod directory. You will be able to use the other tools (except the Emulate tab which currently has a bug related to the source directory) while pointing to this prod directory. You change the XDK project source directory by clicking the "folder icon" in the "Project Info" section of the Projects tab.

If your project does not currently include a www folder inside the project directory, see this forum post and the links it includes > https://software.intel.com/en-us/forums/intel-xdk/topic/623584

Shane_L_
Beginner
110 Views

That's useful to know - that there's no performance benefit. 

That's very helpful 

All the best

Shane

Shane_L_
Beginner
110 Views

Is the built version minified?

 

The original reason I started looking was because my app takes up 50Mb and its just a simple document listing (it's a medical handbook). The data is a tiny portion. I expect the icons take a chunk and the ionic framework. 

When Minecraft PE only takes 33Mb- I'm sure my app could be much smaller. 

I think I'll try concatenation, minification and uglification in a prod folder as you suggest (still not entirely sure how to do it, but will do some more searching)

Ta

Shane

 

PaulF_IntelCorp
Employee
110 Views

Are you sure you're not including old APK files inside your project directory? I've seen some projects where people have done that. Everything that is inside of your "source directory" is included in the build. Your "source directory" is defined on the Projects tab in the Project Info section.

Screen Shot 2016-04-11 at 4.40.25 PM.png

If it is blank (nothing) then it means your project folder and your source folder are the same, which is not good. See this FAQ for instructions on how to fix that > https://software.intel.com/en-us/xdk/faqs/general#www-folder

Double-check to make sure you don't have a bunch of extra things in your "source folder" that are being included unnecessarily in your build. Also, if you do not have an explicit source folder, the plugins directory is automatically excluded, but everything else is included.

Reply