Using Stencil components in Ionic Vue

In the Stencil docs section on framework integration with Vue it states the following:

In order to use the custom element library within the Vue app, the application must be modified to define the custom elements and to inform the Vue compiler which elements to ignore during compilation.

According to the same page this can be achieved by modifying the config of your Vue instance like this:

Vue.config.ignoredElements = [/test-\w*/];

This relates to Vue 2 however. With Vue 3 (which Ionic Vue uses) you have to use isCustomElement as stated here.

However, I can’t for the life of me get Vue and Stencil to play nice. I have tried setting the config like this:

app.config.compilerOptions.isCustomElement = tag => /gc-\w*/.test(tag)

This causes Vue throw the following warning in the console:

[Vue warn]: The `compilerOptions` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, `compilerOptions` must be passed to `@vue/compiler-dom` in the build setup instead.
- For vue-loader: pass it via vue-loader's `compilerOptions` loader option.
- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/p

However, I have no idea how to implement any of the above suggestions using Ionic Vue. I have been messing around with chainWebpack in config.vue.js but without success so far.

Any help would be greatly appreciated.

1 Like