package.json vs config.xml for cordova plugins

前端 未结 2 1442
醉酒成梦
醉酒成梦 2021-01-30 17:00

What is the right way to manage Cordova\'s plugins & platforms ?

On a project using cordova@5.4.0 & ionic-cli@1.7.8, I face 2 possibi

相关标签:
2条回答
  • 2021-01-30 17:40

    Edit: second update! 2017.05.

    It changes again - this time on Cordova side. Cordova 7 adds support for package.json!

    See on Cordova blog: http://cordova.apache.org/news/2017/05/04/cordova-7.html

    Edit: update 2016.05.

    It seems that many ionic commands were created due to lack of the features in cordova, but since cordova caught up and implemented many new features, the ionic maintainers are considering dumping their command like ionic state in favor of the ones provided by cordova.

    So it seems that going the "cordova way" might be more future-proof.

    See those tickets:

    • https://github.com/driftyco/ionic-cli/issues/904
    • https://github.com/driftyco/ionic-cli/issues/1324

    Original answer (2016.03.):

    It's a matter of person taste I'd say. Whatever solution you go through, it's best to be consistent and then always use cordova plugin add ... or ionic plugin add and not mix the two.

    FYI you can have version pinning with ionic's solution, but true, you have to put it manually, or you have to specify the version explicitly during installation e.g. ionic plugin add ionic-plugin-keyboard@1.0.8. Definitely there's room for improvements in ionic CLI regarding that.

    For example, this is our package.json with pinned plugin versions and platform versions as well, and also pinned github SHA1:

      "cordovaPlugins": [
        "ionic-plugin-keyboard@1.0.8",
        "cordova-plugin-inappbrowser@1.2.0",
        "phonegap-plugin-push@1.5.3",
        {
          "locator": "https://github.com/Initsogar/cordova-webintent.git#3d12378de9f38be900761a0ad06ab697cf6d9add",
          "id": "com.borismus.webintent"
        },
        {
          "variables": {
            "APP_ID": "123456789987654321",
            "APP_NAME": "TEST"
          },
          "locator": "cordova-plugin-facebook4@1.6.3",
          "id": "cordova-plugin-facebook4@1.6.3"
        }
      ],
      "cordovaPlatforms": [
        "android@4.1"
      ]
    

    Then when you do ionic state restore it will honor the versions listed.

    0 讨论(0)
  • 2021-01-30 17:41

    i would try using ionic state save and ionic state restore to manage the configuration including plugins... See documentation for more information

    0 讨论(0)
提交回复
热议问题