0
webpack
should be able to create a new chunk with the modules mentioned in the first argument to require.ensure
. It does support having dynamically discovered modules, e.g.:
require.ensure(["./components/" + name + ".vue"], function(){})
would create a chunk with all modules from ./components/*.vue
location – i.e. during the build it will scan the directory and add all *.vue
files.
However, if at runtime you’d try to require
a module that did not exist during build time, it will fail.
While technically you would be able to create a lot of components in a chunk, probably you’d redesign your application to have a single component that behaves differently based on inputs.
Source:stackexchange.com