Webpack 配置问题

Webpack config problems

我正在接手一个别人已经停止维护的小型 React 工具项目。但是,我无法达到 运行。 这是 webpack 配置的问题,我试图以尽可能小的尺寸重建它,但我无法将其构建到 运行.

这是当前的文件

const path = require('path');
const webpack = require('webpack');

module.exports = {
 entry: './client/index.js',
 output: {
  path: path.join(__dirname, 'client'),
  filename: 'bundle.js'
 },
 module: {
     rules:[{
                test: /\.(js|jsx)$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                options: {
                    presets: ['es2015', 'react']
                }
            },
            {
                test: /\.css$/,
                loader: "style-loader!css-loader"
            }],
        
        },
      resolve: { extensions: ['*', '.js', '.jsx'],
        alias: { 'react-dom': '@hot-loader/react-dom'  } },
}
    

这是我遇到的错误:

Error: Compiling RuleSet failed: Exclamation mark separated loader lists has been removed in favor of the 'use' property with arrays (at ruleSet[1].rules[1].loader: style-loader!css-loader)

错误消息说您必须配置使用数组(例如: use: ['style-loader', 'css-loader'] 而不是 loader: "style-loader!css-loader"。以下是来自 webpack 网站的示例。

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
};

您可以在 https://webpack.js.org/loaders/style-loader/

查看详情