解决使用vue-loader15.xx时,已经添加了VueLoaderPlugin,还是报错问题

报错问题:

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

vue-loader15.x以上,都是需要VueLoaderPlugin插件才能正常解析,但添加了还是提示报错。

// webpack.common.js

//在vue-loader中拿到VueLoaderPlugin函数
const { VueLoaderPlugin } = require('vue-loader');

module.exports = {
    ...
    module: {
        rules: [
            {
              test: /\.vue$/,
              loader: 'vue-loader'
            }
        ]
    },
    plugins: [
        ...
        // make sure to include the plugin for the magic
        new VueLoaderPlugin(),
    ]
    ...
}

上面使用不会有问题,但如果使用了speed-measure-webpack-plugin插件,那就会报错

const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const smp = new SpeedMeasurePlugin()

const devModule = {...}

module.exports = smp.wrap(devModule)

【解决】:vue-loader的VueLoaderPlugin好像不能使用speed-measure-webpack-plugin监听,所以只要去除后,vue-loader才能正常解析

你可能感兴趣的:(vue-loader)