博客 / 詳情

返回

解決使用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才能正常解析

user avatar
0 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.