DEV Community

GreggHume
GreggHume

Posted on • Edited on

8

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!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay