I just started working with bower for client-side dependency management. I installed Bower to install all the files in /vendor/assets/components .
Then I run bower install to evaluate the bower.json file and install all the dependencies
#/bower.json { "name": "My-App", "dependencies": { "angular": "1.0.8", "bootstrap": "3.0.0" } }
Finally, in accordance with the instructions that I read, I deleted the component directory from GIT.
#.gitignore
Thus, the project does not include any of these assets in slug and requires bower install run to bower install them.
It seems reasonable to me in the same way that decoupling the real gems from the project is reasonable. It also adheres to the principles of a 12-factor application and explicitly declares and isolates dependencies.
However, the exception of dependencies causes the compilation of assets to throttle ...
However, when I click on Heroku, pre-compilation of the assets fails because the asssets have not been added yet, and therefore, when the asterisks try to evaluate:
#application.css.scss
he found that nothing was found in bootstrap/dist/css/bootstrap because bower hadn't installed anything yet.
Possible solution - use package.json to run post-install script
I followed this tutorial , which suggests adding a package.json file with the following contents:
"dependencies": { "bower": "0.6.x" }, "scripts": { "postinstall": "./node_modules/bower/bin/bower install" }
However, bower install does not need to be run as a post-install script, but after-push compilation of the script. I also wonder if Heroku will run the npm pre-processor for a Rails application
Is it better to figure out how to start a bower installation or just include files in GIT?
There are two solutions. The first and easiest is to simply run bower install locally and include the files in GIT. This is not a biggie, but I would like to adhere to the principles of the 12 Factor App.
The second solution is to figure out how to start npm and run bower install on Heroku before the resources are pre-compiled.
Is this viable in some easy way, or is it better to just compile the database assets locally?
Postscript
In conclusion, I just had to run bower install locally and include the files in GIT. Despite the fact that 12-factor principles suggest that this may not be the right route, I did not consider that it had any costs on it, and would rather have delved into the complexity of complex custom buildpacks.