I have an issue using vue, typescript, webpack and component decorator.
Here is the error
ERROR in ./app/modules/popin-ratings-reviews/templates/HelloWorld.vue?vue&type=script&lang=ts (./node_modules/vue-loader/lib??vue-loader-options!./app/modules/popin-ratings-reviews/templates/HelloWorld.vue?vue&type=script&lang=ts) 10:0 Module parse failed: Unexpected character '@' (10:0) You may need an appropriate loader to handle this file type. | import { Component, Prop, Vue } from 'vue-property-decorator'; | @Component | export default class HelloWorld extends Vue { | message = 'hello world'; @ ./app/modules/popin-ratings-reviews/templates/HelloWorld.vue?vue&type=script&lang=ts 1:0-130 1:146-149 1:151-278 1:151-278 @ ./app/modules/popin-ratings-reviews/templates/HelloWorld.vue @ ./app/modules/popin-ratings-reviews/index.m.ts
It seems that webpack vue-loader can't parse the component decorator syntax. How can I fix that?
I have found the solution
This is the configuration for webpack rules that I use and it is working
rules: [
{
test: /\.tsx?$/,
exclude: [
/node_modules/
],
use: {
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/]
}
}
},
{
test: /\.vue$/,
use: {
loader: "vue-loader"
}
}
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With