def handle(self, **options): js = JsCompressor() css = CssCompressor() cacheable_bundles = {} print green('Compressing JS') for key, bundle in conf.JS_BUNDLES.items(): # compress js bundle storage_url = js.compress(key, bundle) cache_key = get_cache_key(js.media_type, key) cacheable_bundles[cache_key] = storage_url print yellow('-- ' + storage_url) print green('Compressing CSS') for key, bundle in conf.CSS_BUNDLES.items(): # compress css bundle storage_url = css.compress(key, bundle) cache_key = get_cache_key(css.media_type, key) cacheable_bundles[cache_key] = storage_url print yellow('-- ' + storage_url) print yellow('Caching storage urls') set_in_cache(**cacheable_bundles) print green('Done')
def get_bundle_items(media_type, bundle_name): """Returns a list of asset urls. """ if conf.ENABLED: key = get_cache_key(media_type, bundle_name) bundle_url = get_from_cache(key) if bundle_url is not None: return [bundle_url] # return the uncompressed assets return get_bundle(media_type, bundle_name)['files']