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