Open WhyNotHugo opened 2 years ago
I think that this can be fixed by changing manifest_loader.utils.make_url
to remove the leading slash.
However, is there any scenario in which the slash in absent? Otherwise I can't imagine how django-manifest-loader would ever work in non-DEBUG mode.
Actually, the fact that django-manifest-loader uses staticfiles as a backend is problematic (and I realise that's what I was trying to avoid by switching to lib). The hashes added by ManifestStaticFilesStorage imply that js files loaded by js files will have mismatching filesnames. I actually need filenames to remain unchanged, so using staticfiles as a backend is a no-go.
I guess I need to use a custom loader? https://django-manifest-loader.readthedocs.io/en/latest/docs/usage.html?highlight=loader#activating-the-custom-loader
Oh, it's not the loader that delegates to staticfiles, but the manifest
tag itself.
I'm failing to understand how this library is meant to be used. Staticfiles itself adds hashes to scripts, so if one script refers to another, the path doesn't match and it won't load. I currently work around this by compiling everything into one single file (with no hash in its filename) that doesn't load other files, but this has multiple issues (caching is a mess, can't split into multiple script files).
I realised I can use manifest.json
to map to my entry point scripts, which can then load all others with their webpack-given hash directly. I though that django-manifest-loader
would help, but it just uses staticfiles as a backend, so ends up having all the same issues...
But it doesn't seem possible to avoid using staticfiles as a backend? So only running with DEBUG=True
works... What am I missing here?
you may need:
...
output: {
publicPath: 'auto',
},
...
in the webpack config.
Trying to use this in non-debug mode fails:
From what I can tell, the issue is that django-manifest-loader attempts to find files in the staticfiles stoage using the path found in
manifest.json
. The issue is that paths inmanifest.json
have a leading slash, but paths instaticfiles.json
do not.E.g.: