DEV Community

GreggHume
GreggHume

Posted on • Edited on

Vue 3 and Vite: ignore custom components code example

This is how you ignore custom elements in Vue 3 and Vite:

 // vite.config.js
import vue from '@vitejs/plugin-vue'

export default {
  plugins: [vue({
    template: {
      compilerOptions: {
        // i am ignorning my custom '<container>' tag
        isCustomElement: (tag) => ['container'].includes(tag)
      }
    }
  })]
}
Enter fullscreen mode Exit fullscreen mode

As mentioned on this github vite issue:
https://github.com/vitejs/vite/issues/1312

Error you will see before implementing this:

[Vue warn]: Failed to resolve component: container
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
pipeu profile image
Luiz Filipe Couto

Thanks!