我正在尝试在我的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
然而,当我将同一个文件复制到我的app文件夹时,一切都突然开始工作:
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]
为什么会这样?
答案 0 :(得分:0)
看起来您的react-select/dist/react-select.css
使用与css-loader
不同的(第二个)加载程序加载。在您的规则中,您是否将规则应用于广泛的node_modules/
文件?