Path of dynamic chunks is relative
See original GitHub issueThe chunks resulting from a dynamic import are incorrectly loaded into the page. Their path is relative to the page thus
causing 404 errors. To solve this I try to set the publicPath
in Webpack config as suggested in https://github.com/webpack/webpack/issues/7968
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: "/",
filename: "[name].[contenthash].js",
},
Unfortunately that raises a Django SuspiciousFileOperation
:
The joined path (/main.9ce82b7ec94c17ac77f9.css) is located outside of the base path component
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Correctly resolve dynamic chunk paths relative to the current ...
Feature request Correctly load a bundled dynamic javascript import file relative to the current script file. What is the expected behavior?
Read more >React-loadable gets chunks only from relative path
Question: How do I tell react or webpack to use the absolute path /js/ for fetching chunks? Here is my webpack.config.json var path...
Read more >Code Splitting - webpack
Entry Points: Manually split code using entry configuration. Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks.
Read more >Mastering code splitting with webpack | Diel Duarte blog
code splitting is a build time process that splits pieces of your code into async chunks, let's talk about how Webpack can help...
Read more >How code-splitting and dynamic Import works - WPACK.IO
src/main.js', output: { // Create a dir dist in the project root path: ... 'dist'), // filename filename: 'bundle.js', // The URL relative...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for the update @bluesurfer your solution fixed my issue too. Also, thank you @knokit - I made a small update and I now no longer need my custom loader.
I just needed to update my
WebpackManifestPlugin
like thisMy previous comment was too overkill 😃
In my case, I finally solved this issue with the following settings:
Webpack configuration
Django settings
So to me this issue is closed… I’ll let the maintainer @shonin to consider closing this.