Vue加载单文件使用vue-loader报错

报错信息如下

Module Error (from ./node_modules/vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your 
webpack config.

原因

参考官方文档
https://vue-loader.vuejs.org/migrating.html#a-plugin-is-now-required

解决办法如下

// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')

module.exports = {
  // ...
  plugins: [
    new VueLoaderPlugin()
  ]
}

你可能感兴趣的:(Vue)