在使用ant design 时候遇到ant design css 和自定义的css 冲突的问题。
./node_modules/ 中ant desing 的css 文件作为全局的css 和 自定义的css_modules 会发生冲突。解决办法是将/node_modules/中的css与自定义的css 分开处理。即对css_modules使用exclude:/node_modules/
,对node_modules中的css使用include:path.resolve(__dirname,'node_modules')
最开始定义的webpack.config.js 的处理方式:
报错:
ERROR in ./node_modules/antd/lib/button/style/index.css
Module parse failed: /home/johnny/Project/react/demo3/node_modules/antd/lib/button/style/index.css Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
找到解决办法是,分别处理node_modules(ant design)中的css和css_modules: