Bower is described as 'unopinionated' which I guess means that it doesn't try to tell you what to do with the packages it downloads and trusts you to do the right thing. This pleases me as I hate filling my projects full of junk an not knowing what has been altered.
Bower keeps the packages it downloads tidily away in a folder called 'bower_components', I just leave the files in there and reference them from my pages.
I've even started using bower in my Visual Studio projects recently rather than Nuget, I guess that says a lot about how much of my coding has moved to client side over the last year or so.
As with other great tools like Git or Resharper I always feel like I'm only using a fraction of whats there so I was pleased to see a new course on Pluralsight by one of my favorite course authors Joe Eames digging a bit deeper into what can be done with Bower.
As always with Pluralsight it's a great course and having watched it and taken a few notes, i'm now ready to use Bower to manage my dependencies in a smarter way rather than just using it to install packages and nothing else.
Here's what I learnt:
- The .bowerrrc file stores where the files are located so that when you manage your dependencies bower knows where to put them.
- bower init
Rruns you through the creation of a bower.json file for your project. - bower info <packagename>
shows you what versions are available. By default Bower will download the latest. - bower update
updates all your bower installed packages to the latest versions. - bower install <packagename>
not only installs the package initially but is used again to update the package to a later version if available. - bower list
shows your installed packages and dependencies in a tree view. - bower search
searches for bower packages in the bower repository where the title contains specified text. Joe mentions that this does not search descriptions and you'll need to go to the bower website for that. - bower cache clean
Bower keeps a local cache of packages so that if you download the same one more than once for different applications it will use the one it has stored locally if its the newest. - bower install <packagename> --o
Installs the package from the cache in offline mode not checking for the latest version from the Bower repository. - bower install <path>
installs your own package from a local git repository. (the Bower repository is just a GitHub repo) - bower install <urltofile>
Installs a single js file when the full Url to it is provided - bower install <package> --save
saves a reference to the package in the bower.json file meaning that you can check your project in without the packages and pull them in when needed using bower install --production - bower install <packagename> --save-dev
saves a reference to the dev packages in the bower.json file meaning that you can check your project in without the packages and pull them in when needed. - bower help
Lists commands and options - bower help <command>
List deeper info on that command - bower lookup <package>
Gets the GitHub Url to the package. - bower prune
Uninstall any package which is not listed as a dependency in the bower.json file. - bower install <packagename> <packagename> <packagename> --save
Multiple packages can be installed in one go.
Joe goes into a lot more detail and also demonstrates publishing your own project to GitHub, registering it with Bower and then pulling it into a new application with Bower. I'd definitely recommend doing this course. If you don't have a Pluralsight subscription you can get a free trial. This course is only an hour long but there are lots more great courses in there.
Links
Bower Fundamentals - Pluralsight
Joe Eames - Pluralsight
Bower Website
GitHub