Hi all, I was just wondering, what is the accepted way of serving static vendor files with node? I was doing it by using a build script to copy all of the files that would be required by the browser (i.e Bootstrap, jQuery and Font-Awesome) into a vendor directory in my public
directory. The problem is that I added this directory to .gitignore
, so when my app gets deployed to Heroku, the files don’t exist.
I was just wondering what is the best way that I can do this? As near as I can see I have four options:
- Add the front-end files to Git
- Add a static route to serve from `node_modules`
- Use bower instead of NPM for front-end assets and serve from there.
- Completely disregard the front-end files altogether, and instead use a CDN
What would be the best way to do this? Or is it possible to get Heroku to run my build script during the deploy? It’s listed as a script in my package.json
Thanks!
EDIT:
If possible, I would like to avoid using a CDN and my most preferred method would be to get Heroku to some scripts pre-deploy. The reason for this is that I would like to concatenate the minified vendor files so that they can all be retrieved with a single request.
ANOTHER EDIT:
I think I actually found a possible fix. Heroku checks for a heroku-prebuild
script on deploy. I’m assuming that should work to run any build scripts that I want before the app is deployed. I’ll have to wait until I get home to test this but I’m hopeful!