You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
since this is a real pain, as a dirty fix, I've wrote the following code in settings.py
if sys.argv[1:2] != ["collectstatic"]:
css_out = STATIC_ROOT / PIPELINE['STYLESHEETS']['css_files']['output_filename']
js_out = STATIC_ROOT / PIPELINE['JAVASCRIPT']['js_files']['output_filename']
css_replace_done, js_replace_done = False, False
if css_out.exists():
for f in css_out.parent.iterdir():
if f.name != css_out.name and css_out.stem in f.name:
print(f'Found css versioned file: {f.name}')
css_replace_done = True
PIPELINE['STYLESHEETS']['css_files']['output_filename'] = PIPELINE['STYLESHEETS']['css_files']['output_filename'].replace(css_out.name, f.name)
if js_out.exists():
for f in js_out.parent.iterdir():
if f.name != js_out.name and js_out.stem in f.name:
print(f'Found js versioned file: {f.name}')
js_replace_done = True
PIPELINE['JAVASCRIPT']['js_files']['output_filename'] = PIPELINE['JAVASCRIPT']['js_files']['output_filename'].replace(js_out.name, f.name)
if not css_replace_done or not js_replace_done:
raise ValueError('css and js versioned files were not found, make sure collectstatic was called')
It tries to find the hashed files and replaces the output config, which then will be added to the template.
This code assumes one has only one css and js config with the names hard-coded.
It solved the problem for me now, but of course a proper fix from the library would be the ideal way
PipelineCachedStorage
generates hashed files duringcollectstatic
, but the generated URLs reference the files without hashes.Example:
But the rendered django template references
app-build.js
instead ofapp-build.efa204cafb67.js
django = 1.10.5
django-pipeline = 1.6.12
The text was updated successfully, but these errors were encountered: