[Answer]-Makefile with Django collectstatic to gzip assets; Makefile variable depends on target

1đź‘Ť

The best way to solve this is with auto-generated makefiles. Something like this should work OK; add near the top of your makefile (before you use $(CSS_FILES) or $(JS_FILES) for anything):

-include static-output.mk

then add near the bottom of your makefile (or at least, not as the first target):

static-output.mk: bower_components
        python manage.py collectstatic --noinput
        @( echo 'CSS_FILES := $$(shell find static -type f -name "*.css")'; \
           echo 'JS_FILES := $$(shell find static -type f -name "*.js")'; ) \
         > $@

and remove the settings of CSS_FILES and JS_FILES from your makefile and remove the “static” stuff. I don’t really understand what “bower_components” is for or where it comes from so I can’t advise on that.

👤MadScientist

Leave a comment