webpack css-loader 没有加载某些路径

webpack css-loader does not load some paths

我正在尝试像这样在我的 React 项目中导入一个 CSS 文件:

import 'react-select/dist/react-select.css';

这失败并出现错误:

ERROR in ./node_modules/react-select/dist/react-select.css
Module parse failed: /Users/1111/_projects/getmybot/getmybot/node_modules/react-select/dist/react-select.css Unexpected token (8:0)
You may need an appropriate loader to handle this file type.
|  * MIT License: https://github.com/JedWatson/react-select
| */
| .Select {
|   position: relative;
| }
 @ ./frontend/integration-layer-editor.js 13:0-45

但是,当我将同一个文件复制到我的应用程序文件夹时,一切突然开始工作:

import './react-select.css';

输出:

                             Asset    Size  Chunks                    Chunk Names
integration-layer-editor.bundle.js  886 kB       0  [emitted]  [big]  integration-layer-editor
  [93] ./frontend/integration-layer-editor.js 740 bytes {0} [built]
 [200] ./frontend/react-select.css 920 bytes {0} [built]
 [201] ./node_modules/css-loader!./frontend/react-select.css 9.56 kB {0} [built]

为什么会这样?

您的 react-select/dist/react-select.css 似乎是使用与 css-loader 不同的(第二个)加载器加载的。在您的规则中,您是否将规则应用于 node_modules/ 个文件?