在不用VueCli創建項目的時候,手寫引入vue的時候,配置webpack的時候發現了這個問題
webpack vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin
這是因為在15.x.x版本之后,如果要使用vue-loader,需要在webpack種使用vue-loader自帶的插件
VueLoaderPlugin
const path = require('path') // node內置模塊
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const config = {
mode: 'none',
entry: './src/main',
output: {
filename: 'bundle.js',
},
module: {
rules: [
//....
{
test: /\.vue$/,
use: ['vue-loader']
}
],
},
plugins: [
new HtmlWebpackPlugin({
title: 'Webpack Plugin Sample',
template: './src/index.html'
}),
new VueLoaderPlugin()
]
}
module.exports = config