报错:==vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.==

目前,

//两个方式都可以的,随便用一个

const VueLoaderPlugin = require('vue-loader/lib/plugin');

// 或者 

const { VueLoaderPlugin } = require('vue-loader')


plugins: [
    // make sure to include the plugin for the magic
    new VueLoaderPlugin()
]

问题描述:

基本上,加上这样上面这些都是没问题的。但还是会报错,原因在于下面这段代码,

可以看到,加入了resolveLoader之后,所有rules下的loader配置都没有直接跟随后缀-loader ,导致一直再报各种各样的错误信息!

module: {
    rules: [{
      test: /\.js$/,
      loader: 'babel',
    }, {
      test: /\.vue$/,
      loader: 'vue',
    }, {
      test: /\.(css|less)$/,
      include: resolve('/'),
      loader: 'style!css!less',
    }]
}


resolveLoader: {
    moduleExtensions: ['-loader'],
},
解决方案:
module: {
    rules: [{
      test: /\.js$/,
      loader: 'babel-loader',
    }, {
      test: /\.vue$/,
      loader: 'vue-loader',
    }, {
      test: /\.(css|less)$/,
      include: resolve('/'),
      loader: 'style-loader!css-loader!less-loader',
    }]
}

package.json 文件版本置上

{
  "name": "@eid-bi/web-common",
  "author": "",
  "version": "1.0.8",
  "main": "index.js",
  "scripts": {
    "build": "webpack --config ./build/webpack-prod.config.js --mode production --progress --colors",
    "dev": "webpack-dev-server --config ./build/webpack-dev-server.config.js --mode development --progress --colors"
  },
  "license": "ISC",
  "devDependencies": {
    "autoprefixer-loader": "^3.2.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "css-loader": "^1.0.0",
    "html-webpack-plugin": "^3.2.0",
    "ip": "^1.1.5",
    "less": "^3.8.1",
    "less-loader": "^4.1.0",
    "style-loader": "^0.22.1",
    "url-loader": "^1.1.1",
    "vue": "^2.5.17",
    "vue-loader": "^15.4.0",
    "vue-style-loader": "^4.1.2",
    "vue-template-compiler": "^2.5.17",
    "webpack": "^4.17.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.5"
  }
}
Logo

前往低代码交流专区

更多推荐