Vue Vue-loader / VueLoaderPlugin / Webpack


在不用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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM