martedì 13 gennaio 2015

How to use Bower to download libraries for your mobile Cordova apps.

Development of apps or web site requires of many libraries like jquery, etc.
You can use bower as package manager to download libraries and use on your project.
To install bower, nodejs is a prerequisite already installed on your environment:

npm install -g bower

That installs bower binary under your %USERPROFILE%\AppData\Roaming\npm,
at this point you can install packages with bower binary. So if you install latest jquery version for example and save in the manifest file bower.json that keeps tract of all packages available:

bower install jquery --save

On Windows you get the libraries in the package folder:
%USERPROFILE%\AppData\Roaming\npm\node_modules\bower_components\

The package jquery for example is downloaded into folder:
%USERPROFILE%\AppData\Roaming\npm\node_modules\bower_components\jquery

On your mobile project you can now copy into the libraries folder of your project the jquery javascript file and include it in the html

<script src="lib/bower_components/jquery/jquery.js"></script>

For official reference:
http://bower.io/docs/creating-packages/

Nessun commento:

Posta un commento