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:
- npm install
- 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.
Alex
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
config.xml:
<plugin name="wikitudePlugin" spec="https://github.com/Wikitude/wikitude-cordova-plugin.git#v5.1.4-3.2.1"/>
With ionic state save
it’s transfered in the package.json
"cordovaPlugins": [ { "locator": "https://github.com/Wikitude/wikitude-cordova-plugin.git", "id": "com.wikitude.phonegap.WikitudePlugin" } ],
and stored in the plugins
folder. 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.
- 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.
- What the the desired workflow with the
ionic state ...
command? Are there any best practices?
Regards Manuel
UPDATE
- 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
- 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.