[Django]-Compile SASS/SCSS files on Heroku in Django app

3πŸ‘

βœ…

It seems that heroku skipps the compiling scss files part, and pass directly to collecting statics so:

1st step was to disable collecting static files:

heroku config:set DISABLE_COLLECTSTATIC=1

2nd step is to run a post-compile process:

heroku run python manage.py compressscss

and then

heroku run python manage.py collectstatic --noinput 

This can be run automatically by overriding the post-compile of python build pack shown here in this post Link to a how to create postcompile file

Where you create a file in bin/post_compile in the root of the app with:

#!/usr/bin/env bash

cd "$1" || exit 1
python manage.py compilescss --traceback
python manage.py collectstatic --noinput --traceback

And push to Heroku to apply changes.

πŸ‘€ketimaBU

Leave a comment