I'm using Webpack's code splitting / lazy loading feature with a dynamic import
statement. My code looks like that:
import(/* webpackChunkName: "foo" */'../vendor/foo.js').then(() => {
// ...
});
Webpack correctly splits that into its own foo
bundle, however when this code gets executed, Webpack tries to load the file from /foo.js
which results in a 404, as the actual file is served from /js/foo.js
. How do I tell Webpack not to get it from the root?
I figured out I needed to set output.publicPath
.