I kinda answered this question myself. I'm following the code at https://github.com/abhishekmunie/heroku-buildpack-static-css/ and converting to my needs with decent results. I'd recommend anyone else look at that code as it seems fairly platform agnostic.
How can a Heroku php buildpack compile sass / yuicompress before building?
Question
I have a simple php buildpack (based on this here: https://github.com/lenglead/heroku-buildpack-php) that I want to expand to compile my assets on build. I don't want to include compiled/minified css/js in my repo, but Heroku needs it to exist. My idea was as follows:
- Have a script in my repo that compiles the sass and calls a yuicompress on the javascript/css files and places in them in a specific directory.
- Call this in the buildpack before Heroku begins bundling so that when it bundles, it bundles the compiled files in their appropriate location.
However, I'm running into issues since Heroku doesn't have sass/yuicompress installed. I'm very new to Heroku so I'm not sure what direction I should be taking here:
- Download and install sass/yui-compress in my buildpack, then run. (like this: https://github.com/abhishekmunie/heroku-buildpack-static-css/)
- Have them permanently saved on my Heroku app, via a .gemfile. Is this even possible for php apps or are gemfiles just for ruby?
Also I hear people saying that Heroku is 'readonly' so maybe this isn't even possible? Basically, I'd just like to do the compilation on Heroku rather than keep it in the repo.
Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow