Install vue-loader
npm i vue-loader vue-template-compiler
Configure loader
{test:/\.vue$/,use:['vue-loader']}
When the configuration is completed, when using the webpack command to pack, it reports an error:
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.
Reasons for
vue-loader14 and above require additional plugin configuration
Solution 1
Reinstall the lower version of vue-loader
npm un vue-loader
npm i vue-loader@13 -D
Solution two (recommended)
configure plugin in webpack.config.js
1. Add the following code at the head of the file
const VueLoaderPlugin = require('vue-loader/lib/plugin');
2. Add the following code to the module object level
plugins: [ new VueLoaderPlugin() ]
Re-execute the webpack command, no error is reported, the .vue file is successfully compiled and packed