-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config webpack for lazy loading #1096
Comments
The reason this is not working now is that when webpack tries to lookup the location of a dynamically imported module, it looks in In production, I believe we have publicPath set slightly wrong: it's missing a slash on the end (hence webpack looking in In development, we run Hugo on port 3000 and webpack on port 3001. We set webpack asset URLs through Hugo: webpack_url.html partial prepends the webpack url to an input url. By using it, we indicate that assets should be loaded from localhost:3001. But when webpack loads stuff dynamically, it uses URLs based on the
There are some aspects of |
As mentioend in meeting this morning, I think our best course of action is to replace WebpackDevServer (
In particular, having everything on one port makes the dynamic module loading much simpler. I did a little experimentation with this after our meeting. This branch: https://github.com/mitodl/ocw-hugo-themes/pull/new/cc/ww. I think it is largely working, but I haven't tested it too thoroughly. Going to leave this to you and @MAbdurrehman12 , but ask me questions! |
@ChristopherChudzicki Great stuff 👏 |
This is a technical detail of #648 that I think is best handled separately from the videoJS / nanogallery changes.
Webpack (and other bundling tools) support dynamic resource loading along the lines of:
When a dynamic import like
import("./init_videojs_example")
is used:./init_videojs_example
and its dependencies in a separate chunk from the entrypointinitVideoJs
is not loaded. When the import is called (here viainitVideoJs()
) the corresponding chunk is loaded.However, this does not work with our current webpack configuration because of how we've set set publicPath. Currently, lazy-loading like above results in requests like:
Acceptance Criteria
The text was updated successfully, but these errors were encountered: