webpack加入vue的时候报错include VueLoaderPlugin in your webpack config

 

ERROR in ./src/js/login.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
 @ ./src/main.js 7:13-38
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src/main.js

ERROR in ./src/js/login.vue?vue&type=template&id=6eb6567c& 2:0
Module parse failed: Unexpected token (2:0)
You may need an appropriate loader to handle this file type.
| 
> <div>
|     <h1>this is the login area</h1> 
| </div>
 @ ./src/js/login.vue 1:0-84 10:2-8 11:2-17 30:4-35:6 30:68-35:5 32:16-22 33:25-40
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src/main.js

 

运行环境:windows、vue 2.0、webpack 4.8.3

运行npm run build出现问题:

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

解决方案:

在webpack.config.js中添加

const { VueLoaderPlugin } = require(‘vue-loader’)

同时在这个文件中添加

module.exports = {

plugins: [

// 添加VueLoaderPlugin,以响应vue-loader

new VueLoaderPlugin()

]

}

白发渔樵

白发渔樵

发表评论

电子邮件地址不会被公开。 必填项已用*标注