Description
Feature request
What is the expected behavior?
When using require.context
it should be possible to specify the chunk name, same as when using magic comments with dynamic import statements.
Ie it should be possible to write (assuming a 5th argument is added to require.context for the chunk name):
require.context(
'@/views',
true,
/\.async\.vue$/,
'lazy',
'[request]')
which should generate the same chunks as when using
import(
/* webpackChunkName: "[request]" */
`@/views/${name}.async.vue`
);
What is motivation or use case for adding/changing the behavior?
I would like to automatically generate a chunk for every page in a Vue app that meets a certain convention. Ideally the chunk name would be based on the page name.
How should this be implemented in your opinion?
A 5th argument could be added to the RequireContextDependencyParserPlugin
to extract the chunk name and pass it into the RequireContextDependency
options.
Are you willing to work on this yourself?
yes