Search code examples
javascriptcordovapackage-managers

How to add javascript library or packages in cordova?


I am developing Android app using cordova, and I want to add some javascript library in my project. For example, if I want to add async.js, Openlayers and some other library in my cordova app and I don't want to add them manually, how should I resolve this?


Solution

  • We're doing a Cordova app where I work right now.

    We primarily use npm to download any dependencies (like lodash, for example, or any other dependencies available via npm). Then we use webpack to bundle all of the dependencies, and then reference the bundle in www/index.html:

    <script src="bundle.js"></script>