Config.xml versus Package.json (Best Practices)

Some of the plugins I use are saved in config.xml and others are saved in my package.json file. I’ve noticed that when I use “cordova plugin add…” that plugins are added to the config.xml file, and when I use “npm install…” the install settings are saved to the package.json file.

Is there a way to clean this process up? What is the reccommended way to download all files? We have a new member joining the team and I had trouble explaining this part of the project to them, but was able to get through the issue by having them run both of the following commands on initial setup so it installed plugins from both the config.xml and package.json files:

  1. npm install
  2. Ionic state restore

I’m looking for any best practices regarding these two files or if anyone knows why both files are used to do the exact same thing!

Any help is greatly appreciated.


Hi ionic-Team,

I’ve a similar issue/question with ionic2. We have the big wikitude AR (~160mb) plugin in our app which is not in the npm repository

<plugin name="wikitudePlugin" spec=""/>

With ionic state save it’s transfered in the package.json
"cordovaPlugins": [ { "locator": "", "id": "com.wikitude.phonegap.WikitudePlugin" } ],
and stored in the pluginsfolder. Everything fine. The Download takes a while but ok.

When I do ionic platform add ios the plugin is downloaded, and when I do ionic platform add android it’s downloaded again, although it’s already in the plugins folder.

  1. Is there a way to prevent the double download? Cuz it raised the CI build from 4 minutes to 1 hour to build the apk.
  2. What the the desired workflow with the ionic state ...command? Are there any best practices?

Regards Manuel


  1. I fixed the issue by downloading the wikitude plugin tgz into a local folder (~/plugin_store) and changing the spec in the config.xml. In my CI environment the plugins folder is excluded so an ionic plugin rm com.wikitude.phonegap.WikitudePlugin does not work, because the folder is empty. But this is a cordova issue.

I used this fix:
$ sed -ie '/wikitude/d' config.xml #removes the wikitude line in config.xml and saves the file
$ rm -f config.xmle #removes the tmp file from sed
$ ionic plugin add com.wikitude.phonegap.WikitudePlugin --save --searchpath ~/plugin_store #add the plugin from local folder
$ npm install
$ ionic platform add android
$ ionic build android --debug --device

  1. After reading the documentation of ionic-cli and playing around a bit things became clearer. I used now ionic state clear before each stage of my CI.

Did you ever found out the answer to this?

It seems to be different if you use Ionic Cloud or not - I found that the plugin had to be declared in Package.json for the Google Analytics plugin to work with a cloud build.