2017-09-18 122 views
0

我试图导入CSS文件在我的阵营项目像这样:的WebPack 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 

然而,当我同一个文件复制到我的应用程序文件夹中的一切suddently开始工作:

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

看起来好像您的react-select/dist/react-select.css使用不同于css-loader的(第二个)加载程序加载。在您的规则中,您是否有适用于广泛的规则node_modules/文件?

+0

你是对的,我在我的CSS加载器配置中有一个'exclude:/ node_modules /'。谢谢! – kurtgn