Using Bower With Heroku

Written by amanhimself | Published 2016/12/29
Tech Story Tags: javascript | bower | nodejs | heroku | continuous-deployment

TLDRvia the TL;DR App

Yes, I use Bower to maintain front-end dependencies, mostly for my side projects. Whatever you say, Bower is good and I am too anxious to mess with npm dependencies for front-end development. Plus, I feel that maintaining front-end dependencies with Bower helps in keeping my application’s skeleton clean.

So for last two of my projects, I have been using Heroku for deployment. Since I am maintaining front-end dependencies using Bower, I went through this article which is about generating buildpacks on Heroku. I find generating buildpacks adds unnecessary complexity in the process of application deployment, at least for rapid prototyping. Thus, I choose a different path. Adding Bower as an npm dependency seems an easy process and doesn’t add any kind of complexity. I find it’s great only if you are using Bower for rapid prototyping JavaScript applications.

After you are done with building your application, all you have to do is add Bower as an npm dependency in package.json file and then add a script under npm scripts to execute a command that will install bower dependencies before the application is deployed on Heroku.

Bower as dependency in package.json :

"dependencies": {"bower": "1.8.0"}

And then add apostinstall command in npm scripts :

"scripts": {"postinstall": "./node_modules/bower/bin/bower install"}

You can read more about customizing Heroku Build Process here.

Website | See you on Twitter | My articles on Hackernoon.com


Written by amanhimself | Developer, Tech Writer | React Native & Expo enthusiast | Personal blog: amanhimself.dev
Published by HackerNoon on 2016/12/29