Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue-loader parse error for component decorator

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?

like image 578
Mirza Andriamanamisoa Avatar asked Jun 18 '18 14:06

Mirza Andriamanamisoa


1 Answers

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"
    }
  }
  ...
like image 132
Mirza Andriamanamisoa Avatar answered Nov 16 '22 10:11

Mirza Andriamanamisoa