當咱們寫好 app.vue webpack.config.js 後 滿心歡喜的在命令行輸入vue
npm run build
複製代碼
後結果發現報出webpack
vue-loader was used without the corresponding plugin. Make sure to include
複製代碼
此時會有兩種狀況:web
在Terminal輸入npm
npm install vue-loader
複製代碼
此時問題應該已經解決bash
在webpack.config.js文件中添加app
const {VueLoaderPlugin} = require('vue-loader')
module.exports={
...
plugins:[
new VueLoaderPlugin()
],
module:{
rules:[
{
test:/.vue$/,
use:'vue-loader' //在webpack4.0中用use取代loader
}
]
}
}
複製代碼
注:const {} = require() 爲ES6的解構賦值ui