Using Bower With Heroku

Dec 29, 2016

2 min read

#tools

Originally Published at Hackernoon.com

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 :

JSON icon

1"dependencies": {
2 "bower": "1.8.0"
3}

And then add apostinstall command in npm scripts :

JSON icon

1"scripts": {
2 "postinstall": "./node\_modules/bower/bin/bower install"
3}

You can read more about customizing Heroku Build Process here.


⬅️ Previous: Migrating from Expressjs 4 to 5

Next: Writing a Node.js Twitter Bot Part 2 ➡️

Enjoyed this post? Sign up to my newsletter!

A periodic update about my recent blog posts and tutorials. Join 1300+ devs!

No spam, unsubscribe at any time!

Subscribe on Revue

HomeBlogNewsletterAbout meSpeakingEmail

©  2019-2022 Aman Mittal · All Rights Reserved