Allow multiple entries when using build with the target flag.
See original GitHub issueWhat problem does this feature solve?
It would allow users to build multiple libraries at once, ideally this would be usable with the --watch
flag.
I have posted a detailed issue on the forum describing my use case for those interested, but after looking at the code I can see that this will most likely require updates to the internal structure of the Vue cli.
This is primarily aimed at people building modular component libraries on top of Vue (particularly ones that can be loaded from a CDN which is my use case).
For additional background I am trying to pre-compile my components (using --target lib
) and then load them over http using the technique outlined here but that is outside of the context of what I am actually asking for.
What does the proposed API look like?
If no path is provided when using build with the --target
command fallback to the entries config (particularly the one in vue.config.js
) ie:
config.entryPoints.delete("app");
// Add entry points
config
.entry("component-one")
.add("./src/components/ComponentOne.vue")
.end()
.entry("component-two")
.add("./src/components/ComponentTwo.vue")
.end();
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:21 (2 by maintainers)
Top GitHub Comments
Another use case for this is when you embed Vue into an existing non-SPA application. To modernize pages separately you’ll need to build a Vue library for each one of them, so multiple entries is a necessity to avoid (1) invoking
vue-cli-service
multiple times during production build (2) supporting dev workflow whenvue-cli-service
should run in the background and watch for changes.🙋♂ hi, hello, yes. this is me. this is exactly what I’m trying to do.
Currently I’m just doing
vue-cli-service build --target lib --name my-lib-name ./src/index.js
(where index.js has a list of imports and named exports for each component). This results in a single output file… but consumers of the library would still be importing ALL components unless they have tree-shaking turned on.The problem we are running in to now is that some consumers are doing SSR… and not all components are SSR-friendly (they relay on browser APIs like localStorage, etc). But because everything gets rolled in to a single file… even if they import an SSR-friend component, an error still happens because it’s trying to evaluate the entire file (this is specific to non-production / local dev mode, where tree-shaking is never enabled).
So now we are looking to create an individual export file per component. But just realized that the vue-cli-service does not allow for multiple inputs nor multiple outputs (I tried doing
vue-cli-service build --target lib ./src/**/*.vue
which did not give an error… but did produce a rather bizarre file with not my components haha).I did come across this issue which is somewhat related: https://github.com/vuejs/vue-cli/issues/2744, which is not ideal but does get us a closer to what we need.
Anyways… that is just a very long-winded way of saying that I would love for vue-cli-service to support multiple and dynamic entry points 🙏