django-webpack-loader
django-webpack-loader copied to clipboard
Need help with render_bundle after changing directory structure
We have a legacy Django-webpack app using Django webpack loader. The app code moved into a /app directory and the render_bundle stopped working. The error message is
File "/usr/local/lib/python3.9/site-packages/webpack_loader/templatetags/webpack_loader.py", line 22, in render_bundle
tags = utils.get_as_tags(
File "/usr/local/lib/python3.9/site-packages/webpack_loader/utils.py", line 71, in get_as_tags
bundle = _get_bundle(loader, bundle_name, extension)
File "/usr/local/lib/python3.9/site-packages/webpack_loader/utils.py", line 47, in _get_bundle
bundle = loader.get_bundle(bundle_name)
File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 116, in get_bundle
filtered_chunks = self.filter_chunks(chunks)
File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 58, in filter_chunks
ignore = any(regex.match(chunk)
File "/usr/local/lib/python3.9/site-packages/webpack_loader/loader.py", line 58, in <genexpr>
ignore = any(regex.match(chunk)
TypeError: expected string or bytes-like object
Versions: django-webpack-loader: 1.6.0 webpack-bundle-tracker: 0.4.3
webpack-stats.json {"status":"done","publicPath":"http://localhost:8001/","chunks":{"app":[{"name":"app.js","publicPath":"http://localhost:8001/app.js","path":"/app/static/dist/app.js"}]}}
I hard-coded our STATICS_URL to try to match the documentation on django-webpack-loader STATIC_URL: /app/static/dist/ WEBPACK PATH(output.path): /app/static/dist
Code that triggers the error: {% render_bundle 'app' %} inside a index.html
WEBPACK_LOADER:
BASE_DIR = "/app"
STATIC_URL = "/app/static/dist/"
STATIC_ROOT = Path(BASE_DIR, "public")
STATICFILES_DIRS = [
Path(BASE_DIR, "static"),
Path(BASE_DIR, "static", "dist"),
]
WEBPACK_LOADER = {"DEFAULT": {"CACHE": not DEBUG}}
@gggrunt could you please try upgrading your webpack-bundle-tracker to 1.6.0? Try to always match versions between webpack-bundle-tracker and django-webpack-loader.
I'm also experiencing a similar issue, a TypeError when webpack-stats.json is parsed in django-webpack-loader. My webpack-stats is similarly built. Both webpack-bundle-tracker and django-webpack-loader are installed as version 1.6.0.
@camvrgs sorry you're having issues, please share the whole error stacktrace.
Hi @camvrgs, this looks similar to this issue https://github.com/django-webpack/django-webpack-loader/issues/324. We'll be updating any findings regarding this problem there.
@camvrgs @gggrunt
Please confirm you have the same version in django-webpack-loader and webpack-bundle-tracker like django-webpack-loader==1.6.0 and [email protected]. Both libs should always have the same version in projects.
This seems a duplicate of issue #324. Check this comment: https://github.com/django-webpack/django-webpack-loader/issues/324#issuecomment-1270691083
Closing for now.