django / django/new-features

Warn instead of error for missing sourcemap files during collectstatic

Open
#173 5 comments 5 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

When post_processing js/css files during collectstatic with ManifestStatifilesStorage it should warn about missing sourcemap files instead of raising an error and preventing and further processing of files.

### Problem

It can happen that you install a third party lib, and only include the main js/css file in your static directory. The file points to a sourcemap file, but you haven't downloaded it, as it's not something you are overly concerned about, especially if you are a beginner. But when you run collectstatic you end up with a confusing error (that we have tried to improve recently). It would be better to give a warning and let the rest of the collectstatic work.

This also affects third party django apps, after doing an [audit of djangopackages](https://github.com/blighj/django-manifeststaticfiles-enhanced/wiki/collectstatic-benchmark) I found several that include /static folders with files referencing missing sourcemaps. So a developer who wants to use their project and ManifestStatifilesStorage has to know how to use the the `--ignore` option of colelctstatic, or how to add a /static path to the sourcemap mimicing the static structure of the third party app, as they have no way other than a bug report to change the actual js/css.

### Request or proposal

proposal

### Additional Details

There is a similar problem with local build js files in your /static folder when using the `support_js_module_import_aggregation` option. A warning approach could be used when encountering those `import * from "./jquery"` during collectstatic.

I still think it makes sense to raise the error for missing images, font files, actual css/js imports, etc. As in those cases their is a high probability chance that your project's frontend won't work without the assets and it's good to be told straight away.

### Implementation Suggestions

There is prior art implementation in https://github.com/blighj/django-manifeststaticfiles-enhanced/

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.