Webpack错误:规则只能有一个结果源(提供的用法和加载程序)

此Webpack错误表示什么?

Error: Rule can only have one result source (provided use and loaders) in {
  "test": {},"loaders": [
    "style-loader",{
      "loader": "css-loader","options": {
        "importLoaders": 1
      }
    },{
      "loader": "postcss-loader","options": {
        "plugins": [
          null
        ]
      }
    }
  ],"use": [
    "style-loader","vue-style-loader","options": {
        "plugins": [
          null
        ]
      }
    }
  ]
}

这是我的webpack.config.js:

const path = require('path');
const package = require('./package');

module.exports = {
    mode: 'development',resolve: {
    },module: {
        rules: [
            {
                test: /\.vue$/,loader: 'vue-loader',},// this will apply to both plain `.js` files
            // AND `<script>` blocks in `.vue` files
            {
                test: /\.js$/,loader: 'babel-loader'
            },// this will apply to both plain `.css` files
            // AND `<style>` blocks in `.vue` files
            {
                test: /\.css$/,use: [
                    'vue-style-loader','css-loader'
                ]
            },{
                test: /\.svg$/,include: [path.join(__dirname,'public/icons/svg')],loaders: [{
                        loader: 'svg-sprite-loader',options: {
                            symbolId: '[name]',{
                        loader: 'file-loader',options: {
                            name: 'public/[name].[ext]?[hash]',}
                    },{
                        loader: 'img-loader',}
                ]
            },{
                test: /\.(ttf|woff)$/i,loader: 'file-loader',{
                test: /\.(md|yml)$/,loader: 'null-loader'
            }
        ],}
};
qzrobinh 回答:Webpack错误:规则只能有一个结果源(提供的用法和加载程序)

webpack版本可能存在问题。

尝试切换较低版本。

npm uninstall webpack
npm install webpack@^4.0.0 --save-dev
,

或将css-loader降级为3.6,对我来说有效:

npm uninstall css-loader
npm install css-loader@3.6.0

带有postcss-loader的IDEm降级到3.0

npm uninstall postcss-loader
npm install postcss-loader@3.0.0
本文链接:https://www.f2er.com/3156107.html

大家都在问