webpack dynamic import naming doesn't work
See original GitHub issueI used comment to define chunkname as follows:
import(/* webpackChunkName: "chunk1" */'../components/chunk1.js')
then change webpack config output.chunkFilename: utils.assetsPath('js/[name].js')
but the build result has no file named chunk1.js.
At first I thought it’s a webpack bug. so I post an issue on webpack: https://github.com/webpack/webpack/issues/4861
But then I made a simple project without vuejs-template , chunkname works fine.
So I think there must be something wrong in the config of this template, could you help me find out ?
My test project: https://github.com/MarvinXu/webpack-chunkname-test
many thx!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
dynamic import naming doesn't work · Issue #4861 - GitHub
In my TypeScript+Webpack case, { "module": "commonjs" } caused the problem. It worked fine on "es5" and "esnext".
Read more >How to generate dynamic import chunk name in Webpack
You can use [request] placeholder to set dynamic chunk name. A basic example would be: const cat = "Cat"; import( /* webpackChunkName: "[ ......
Read more >Fixing WebpackChunkName for Dynamic Imports - Time to Hack
Are the Webpack Magic Comments webpackChunkName not effective and working with Babel? See how to Fix it and Tips to avoid related problems....
Read more >How Webpack Handles Dynamic Imports with Variable Paths
Whenever you import a file in your code, Webpack will look for it in the project directory and copy it to the build...
Read more >How to name a webpack chunk (including split and common ...
In this post, we look at named outputs, including dynamic imports, split chunks, and common chunks. I recently wrote about code splitting ...
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
In your
.babelrc
config file, make surecomment: true
is used. Inbuild/webpack.prod.conf.js
file, make sureoutput.chunkFileName
contains[name]
. Example:In my opinion, There’s no need to add it to the docs because it’s the default value.
Back when this issue was relevant, we had
comments: false
in the Babel config, but that was months ago.Adding something about this to the doc would be starting a list of “don’t do this” about general webpack features.