cordova-x-filter v0.0.5
cordova-x-filter (beta... works for me...)
Cordova hook that allows you to filter (whitelist/blacklist) the files that are included in your final .apk to save size wich is very important!
2 Examples:
- Are you using jquery?
npm install jquery --savehave you noticed it brings 144 files/folders and its 1.3MB but you only usedist/jquery.min.jsin your cordova app 87kB... - Are you using the latest font-awesome?
bower install font-awesome@latest --saveit brings 3342 files/folders and 17.3MB. What? Yep! But you but you will probably only useweb-fonts-with-cssand that's 2.3MB and you can even filter it further with this tool if you only use one of the font variants...
All this brings clutter that increases your .apk size if you are not careful...
Install
Install the following package below inside of your apps root folder.
npm install cordova-x-filter --saveAfter install an after_prepare folder will be added to your hooks folder with the x-filter.js script in it. A JSON config file (x-filter-config.json) for the script will be added to the hooks folder. The hook will automatically be given executable permission.
Usage
ionic cordova run androidor if you are releasing or changed alwaysRun on x-filter-config.json
ionic cordova build android --releaseYou a similar output to this:
CLEANING!
All Files: 3630
Whitelisted Files: 101
Blacklisted Files: 0
FINISHEDDefault Configuration
{
"alwaysRun": true,
"whitelist": [
"index.html",
"cordova.js",
"cordova_plugins.js",
"plugins/**",
"cordova-js-src/**",
"js/**"
],
"blacklist": [
]
}(Those are the minimum required files for a cordova app to work.)
Using cordova-x-filter with Ionic 2
I haven't used Ionic 2 but aparently you might need to add build on your files/folders whitelisted/blacklisted
Requirements
Latest cordova/android (cordova Android 7.0.0?) because they changed the folder structure.... if you are using a previouse version change this line(s): https://github.com/rossmartin/cordova-uglify/issues/41
