vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Add unprefixed option when building multiple web components #6408

Open aranoe opened 3 years ago

aranoe commented 3 years ago

What problem does this feature solve?

It keeps your vue component names consistent with the web component output. When using wc-async for multiple web components as a build target, it should be possible to not prefix the component names.

Build Script:

"build:wc-async": "vue-cli-service build --target wc-async --name xyz 'src/components/**/Xyz*.vue'"

Example component name:

XyzNavigation.vue 

Expected Result

<xyz-navigation></xyz-navigation>

Actual Result

<xyz-xyz-navigation></xyz-xyz-navigation>

It should not add the prefix, since the file name already contains it.

What does the proposed API look like?

It might make sense to add --unprefixed option to the build :

"build:wc-async": "vue-cli-service build --target wc-async --name xyz 'src/components/**/Xyz*.vue' --unprefixed"
bjornstenfeldt commented 3 years ago

The ability to disabled prefixes is actually super important, if anyone ask me. We have 50+ portals using hundreds of Vue apps written as native JS apps. They are mixed with our existing code. Maybe we have 20-30 small Vue apps running on each page.

Now we want to migrate to typescript and compile .vue files, but this prefix-thing is not helping at all. We will be forced to find, check and correct every single Vue app on every single page, to make sure that the prefix is applied everywhere. Horrible.