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

vue项目打包报错vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin_第1张图片

首先:保证自己有没有安装vue-loader以及vue-template-compiler

npm install vue-loader vue-template-compiler -D

其次:vue-loader的使用都是需要伴生 VueLoaderPlugin的,要配置webpack.config.js

const path = require('path')
//const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
  mode:'production',
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  // plugins: [
  //   new VueLoaderPlugin()
  // ],
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: {
          loader: 'vue-loader'
        }
      }
    ]
  }
}

把注释的代码加上
1.const VueLoaderPlugin = require(‘vue-loader/lib/plugin’);
2.plugins: [
new VueLoaderPlugin()
]

注意webpack4的写法不同,module里这么写有时不管有

module: {rules: [ { test: /.vue$/, loader: ‘vue-loader’ } ] }

你可能感兴趣的:(vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin)