ketimaBU
ketimaBU

Reputation: 949

Compile SASS/SCSS files on Heroku in Django app

I am getting an error when DEBUG is set to False or unset in Heroku, in Django app, when I activate logs.

ValueError: Missing staticfiles manifest entry for 'css/sass/home.css'

Seems that my SCSS files are not compiled when I deploy on Heroku, while it compiles automatically locally with django-sass-processor

Upvotes: 3

Views: 1003

Answers (1)

ketimaBU
ketimaBU

Reputation: 949

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.

Upvotes: 3

Related Questions