问题描述:使用create-react-app 脚手架创建的react + antd 应用,antd 组件没有被antd底层的样式文件渲染(css或less,js文件未被执行)
解决方案:
npm install --save-dev babel-plugin-import react-app-rewired
根目录下创建config-overrides.js
const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {
// do stuff with the webpack config...
config = injectBabelPlugin(['import', { libraryName: 'antd-mobile', style: 'css' }], config);
return config;
}
注:当然,使用react-app-rewired
,package也要做相应的修改
网友评论