Skip to content

Commit

Permalink
Fix issue with Heroku + Django Compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Jul 4, 2020
1 parent 6f76309 commit 68116dc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ tags
### VirtualEnv template
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
Expand Down
7 changes: 7 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def remove_heroku_files():
# don't remove the file if we are using travisci but not using heroku
continue
os.remove(file_name)
remove_heroku_build_hooks()


def remove_heroku_build_hooks():
shutil.rmtree("bin")


def remove_gulp_files():
Expand Down Expand Up @@ -346,6 +351,8 @@ def main():

if "{{ cookiecutter.use_heroku }}".lower() == "n":
remove_heroku_files()
elif "{{ cookiecutter.use_compressor }}".lower() == "n":
remove_heroku_build_hooks()

if (
"{{ cookiecutter.use_docker }}".lower() == "n"
Expand Down
1 change: 0 additions & 1 deletion {{cookiecutter.project_slug}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ tags

### VirtualEnv template
# Virtualenv
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
Expand Down
22 changes: 22 additions & 0 deletions {{cookiecutter.project_slug}}/bin/post_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

compress_enabled() {
python << END
import sys
from environ import Env
env = Env(COMPRESS_ENABLED=(bool, True))
if env('COMPRESS_ENABLED'):
sys.exit(0)
else:
sys.exit(1)
END
}

if compress_enabled
then
python manage.py compress
fi
python manage.py collectstatic --noinput

0 comments on commit 68116dc

Please sign in to comment.