Skip to content

Utility function for uploading to static storage #279

@jdahlin

Description

@jdahlin

I ended up writing this snippet that uploads webpack assets to the static storage. This might be useful for someone else and couple be included in webpack-loader itself.

from django.conf import settings
from django.contrib.staticfiles.storage import staticfiles_storage

from webpack_loader.utils import get_loader


for config_name in settings.WEBPACK_LOADER:
    loader = get_loader(config_name=config_name)
    chunks = loader.get_assets()['chunks']
    for assets in chunks.values():
        for asset in assets:
            with open(asset['path'], mode='rb') as f:
                staticfiles_storage.save(asset['name'], f)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions