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

问题

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
. Vue-loader在15.*之后的版本都是 vue-loader的使用都是需要伴生 VueLoaderPlugin的

解决方法

  1. 将vue-loader版本回归成14.* (查询版本传送门:https://www.npmjs.com/package/vue-loader)
    ps:最后一个14的版本是14.2.2, npm install [email protected]

  2. 修改webpack.config.js

const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
    devtool: "sourcemap",
    entry: './js/entry.js', // 入口文件
    output: {
        filename: 'bundle.js' // 打包出来的文件
    },
    plugins: [
        // make sure to include the plugin for the magic
        new VueLoaderPlugin()
    ],
    module : {
        ...
    }
}

你可能感兴趣的:(Vue)