Re: [flask] Flask-Assets and Heroku
- Audrius Kažukauskas
- 2013-05-29 @ 20:02
On Wed, 2013-05-29 at 13:33:11 -0400, Freedom Dumlao wrote:
> Does anyone out there have a good process for using Flask-Assets (or even
> just webassets) with Heroku? I'm trying to find a good way to pre-build the
> assets before pushing to Heroku and then preventing it from trying to build
> them again once it's been deployed.
I'm doing this on my Linode VPS for personal projects, but don't see any
reason why it shouldn't work for Heroku, although I may be wrong here,
have tried Heroku only once and it was long ago.
In my webapp's main .py file:
assets = Environment(app)
# Disable asset rebuilding in production mode.
if not app.debug:
assets.auto_build = False
assets.manifest = 'file'
# ... Further assets configuration follows ...
I don't recall exact reason why manifest is set to 'file', but I think
it's because otherwise whole .webassets-cache/ directory would be
The webapp is a proper Python package[*] and is configured to use
Flask-Script (has manage.py). MANIFEST.in contains the following lines
(all.css and all.js is minified and concatenated CSS and JS code):
from flask.ext.assets import ManageAssets
For deployment I am using good old shell script (again, this is for
personal projects on a single VPS), but you can use whatever suits you
best (or what Heroku provides). The relevant part from the shell
rm -f $ASSETS_DIR/.webassets-manifest
$PYTHON manage.py assets clean
$PYTHON manage.py assets build --manifest $ASSETS_DIR/.webassets-manifest
$PYTHON setup.py sdist --format=gztar
After executing this inside dist/ directory there will be a tarball of
the webapp, ready to be transfered to a server and pip-installed into a