diff --git a/packages/plugin-vue/README.md b/packages/plugin-vue/README.md index d5b45a63..998a8146 100644 --- a/packages/plugin-vue/README.md +++ b/packages/plugin-vue/README.md @@ -182,6 +182,18 @@ The `customElement` plugin option can be used to configure the behavior: - `{ customElement: true }` will import all `*.vue` files in custom element mode. - Use a string or regex pattern to change how files should be loaded as Custom Elements (this check is applied after `include` and `exclude` matches). +### Special Query + +Special query can be used to load the Vue component as a custom element without changing the file extension or global configuration: + +```js +import { defineCustomElement } from 'vue' +import Example from './Example.vue?customElement' + +// register +customElements.define('my-example', defineCustomElement(Example)) +``` + ## License MIT diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 811c7167..6ddb12b9 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -257,7 +257,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { options, this, ssr, - customElementFilter(filename), + customElementFilter(filename) || 'customElement' in query, ) } else { // sub block request