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
Allow webpackChunkName to be specified when using require.context #9184
Comments
that would be nice, as require.context doesnt generate any chunk |
const children = context.keys().map(key => {
const path = key
.split('/')
.map(str => str.replace(/\.vue/g, '').replace(/\./g, ''))
.filter(str => str !== '');
return {
component: () => context(/* webpackChunkName: "[request]" */ key),
name: `${ctxKey}-${path.join('-')}`,
path: `${ctxKey}/` + path.join('/')
};
}); @DaniJG |
This issue had no activity for at least three months. It's subject to automatic issue closing if there is no activity in the next 15 days. |
bump |
up. This issue is still relevant, especially considering that dynamic imports don't offer a feature similar to require.context |
bump this issue |
bump this issue |
bump this issue |
This has been implemented since years |
Where can I find the documentation or example? |
Oh I misread this as No this is not implemented, but it's not that difficult to add. Send a PR. see RequireContextDependencyParserPlugin.js, add |
Okay, I'm starting a PR I believe we should have control over the chunkName, just |
PR implements the same features as import with comments So now it would be possible to do require.context(
/* webpackMode: "lazy" */
/* webpackChunkName: "[request]" */
'@/views',
true,
/\.async\.vue$/
) |
please use |
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):
which should generate the same chunks as when using
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 theRequireContextDependency
options.Are you willing to work on this yourself?
yes
The text was updated successfully, but these errors were encountered: