vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin

场景

webpack版本:4.29.6
vue-loader版本: 15.7.0

在使用webpack手动构建Vue项目时,突然报出这个错误:
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

分析

Vue-loader在15.*之后的版本都是 vue-loader的使用都是需要伴生 VueLoaderPlugin的。

解决

在webpack.config.js中添加vueLoaderPlugin插件

const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
  entry: './src/main.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [{
      test: /.vue$/,
      use: 'vue-loader'
    }]
  },
  plugins: [
    new VueLoaderPlugin()
  ]
}

你可能感兴趣的:(webpack)