I'm running a TypeScript based Vue project and am trying to build it as a web component using @vue/web-component-wrapper.
Related code:
// main.ts
import JovoWebClientVue, { JovoWebClientVueConfig } from 'jovo-client-web-vue';
import Vue from 'vue';
import App from './App.vue';
import wrap from '@vue/web-component-wrapper';
Vue.config.productionTip = false;
Vue.use<JovoWebClientVueConfig>(JovoWebClientVue, { /* cut */ });
new Vue({
render: (h) => h(App),
}).$mount('#app');
const wrappedElement = wrap(Vue, App);
window.customElements.define('v-card', wrappedElement);
// App.vue
<template>
<div id="app" class="w-screen h-screen">
<chat-widget />
</div>
</template>
<script lang="ts">
import ChatWidget from '@/components/ChatWidget.vue';
import { Component, Vue } from 'vue-property-decorator';
@Component({
components: { ChatWidget },
})
export default class App extends Vue {}
</script>
<style>
@import 'assets/css/theme.pcss';
#app {
-webkit-tap-highlight-color: transparent;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>
When running the build command:
vue build --target wc --name my-custom-element ./src/main.ts
I get the following error:
Module parse failed: Unexpected character '@' (11:0)
You may need an additional loader to handle the result of these loaders.
| import { Component, Vue } from 'vue-property-decorator';
|
> @Component({
| components: { ChatWidget },
| })
Any idea how to resolve this? Appreciate all help - thank you.