miracle2k / django-assets

Django webassets integration.
BSD 2-Clause "Simplified" License
89 stars 79 forks source link

Compiled assets not added to Django's staticfile manifest #56

Closed longhotsummer closed 9 years ago

longhotsummer commented 9 years ago

I run collectstatic and then build assets to compile and version my assets in production (webassets does the versioning). I use Whitenoise to serve production assets and (in theory) ensure far-future expire headers for fingerprinted assets.

However, Whitenoise doesn't think the compiled, versioned assets should have an far-futures expired header set because they aren't in the staticfiles.json manifest.

If I run collectstatic again after build assets it fingerprints the already fingerprinted files.

Is there a way we can solve this or work around it?

Key parts of my settings.py:

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

In assets.py:

from django_assets import Bundle, register

register('css', Bundle(
    # list 3rd party and raw css here
    'bower_components/fontawesome/css/font-awesome.css',
    Bundle(
        # list SCSS files here
        'stylesheets/app.scss',
        filters='pyscss',
        output='css/styles.%(version)s.css'),
    filters='cssrewrite',
    output='css/app.%(version)s.css'))
miracle2k commented 9 years ago

Not being up to date with Django, this is the first time I hear about staticfiles.json.

I have two ideas:

longhotsummer commented 9 years ago

My vote is for django-assets being aware enough to add entries to staticfiles.json. Does the webassets builder return the output filenames for what it has compiled?

miracle2k commented 9 years ago

I'm sure there is some way to get at the info. The right place would probably be an overwritten version of the "build" command.