Closed manstie closed 3 years ago
Hi @manstie, I'm not understanding what exactly you want to do. If you're using this app, django-manifest-loader
, you can import all files with a single tag, where the first argument is the pattern to match, and the second argument is what string to embed the matched file path into:
{% load manifest %}
{% manifest_match '*.js' '<script src="{match}"/>' %}
Please not that this app is not designed to work with webpack-bundle-tracker
. django-webpack-loader
is a different app from this one, which is designed to work with webpack-bundle-tracker
.
This app uses webpack-manifest-plugin
The point is I do not want to import every file on one page because I have created multiple bundles/apps, and my webpack config has multiple entry-points.
So for this feature to work, the output of webpack-manifest-plugin
would have to have an option, and webpack-manifest-loader
would have to have a function to allow for specific bundle (and its dependencies) importing only.
I understand the difference between the two sets of applications, and I was trying to explain the feature of the old unmaintained repos.
Okay. I think I see what you're saying. I'll admit that it's been several years since I used django-webpack-loader
, and I wrote this app instead of having to learn it again. I'm working on a pull request (#22) right now that allows the implementation of custom loaders. I'm pretty sure a custom loader could be used to do what you want to do. Once I finish that PR I might look into building a loader for this to help people transition from one app to the other.
Sounds good, thanks for working on that.
@manstie the custom loaders have been released and are available in the latest version of this package. You can build a custom loader that will allow you to parse through the manifest file as you choose. This should let you implement compatibility for the manifest file generated by webpack-bundle-tracker
.
Documentation on how to build a custom loader can be found here: https://django-manifest-loader.readthedocs.io/en/stable/docs/usage.html#custom-loaders
Seeing how webpack-bundle-tracker
is no longer maintained I will not be implementing a loader for it into the source code of this package. If you do build a loader I encourage you to share the source code of it here so that others in the future may be able to find it.
PS this draft of a loader I built for create react app is pretty close to what you'd want to implement for this: https://github.com/shonin/django-manifest-loader/pull/33/files#diff-52d43aa2f47a3b5faa105d50717c0277a2af1a9dc404e43860e3d42719b5f051R29
Nice work.
I have
webpack-bundle-tracker
anddjango-webpack-loader
in a working state after manually fixing them, but as part of my CI/CD it is not viable to do this.A thing that I noticed this project does not do is link which npm packages are used in which bundles when you follow the tutorial which got me into this in the first place (which you also link in your readme) which makes all the npm packages into different .js files to save bandwidth with caching.
Here's an example of the output of
webpack-bundle-tracker@1.0.0-alpha1
(note it does not do this in 0.4.3):With the output above, I was able to do
{% render_bundle 'board' %}
and it would import all the files as seen above under the 'board' chunk.I believe this is a mandatory feature, as I do not want to be keeping track and/or guessing which npm package I use in which bundle, thus forgetting to add or remove a script tag in my HTML.
I also do not know the significance of the
runtime.js
file webpack outputs when you have multiple entry files andruntimeChunk: 'single',
in your webpack config, but I assume it should be imported when using any of the bundles?You could even go further as to support webpack's
dependOn: 'x',
flag, and have the bundles that depend on other bundles automatically imported also, which is something the older project does not do.With all that in mind, it should probably prevent importing the same file twice in one document?
Thanks for creating and maintaining this project. Please let me know if this feature is possible for you to implement.