Why should I use Bower?

What is Bower?

Bower is a package manager for front-end frameworks.

Why should I use Bower?

It’s arguably simpler to use Bower as your package manager for front-end development than to use NuGet.

  • It can create a bower.json file that lists all of your dependencies.
  • It’s easily driven from the command line.
  • It separates out the concerns of the front-end from those of the back-end.

Of great benefit is it’s a single point of access to thousands of front-end packages that just aren’t available as NuGet packages. Previously you would have had to download and install the Javascript and the CSS. The process would have varied from project to project and there was no obvious upgrade path to the latest versions.

Starting with ASP.NET 5.0 there will be no more NuGet packages for front-end frameworks like Twitter Bootstrap. Microsoft currently create these packages using Bower but will now be expecting you to tool up with Bower yourself. Might as well get started early.

How do I use Bower?

This gets a bit gnarly, mainly because we’re behind a corporate proxy that expects authentication and tools like npm and bower aren’t clued up about that.¬†You need to set up a proxy server locally to handle NTLM authentication. I’ve been successful with CNTLM.

  • set up CNTLM
  • install node (.msi)
  • set up .npmrc
  • $ npm install -g npm
  • ensure %appdata%\npm is before %ProgramFiles%\nodejs in the PATH
    (npm wiki: upgrading-on-windows)
  • $ npm install -g bower
  • set up .bowerrc
  • $ bower install bootstrap

You can now reference your bower_components directly from your includes or you can configure a Gulp/Grunt build.

Where do I find out more?

Bower
Introducing Gulp, Grunt, Bower, and npm support for Visual Studio

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s