按照文中配置,babel-plugin-import。页面按钮没有样式,
需要在app.js中手动导入
import ‘antd/dist/antd.css’ 才会展示button样式
config-overrides.js 如下
const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {
config = injectBabelPlugin(['import', { libraryName: 'antd', style: 'css' }], config);
return config;
};
App.js代码如下
// src/App.js
import React, { Component } from 'react';
import { Button } from 'antd';
import 'antd/dist/antd.css'
class App extends Component {
render() {
return (
<div className="App">
<Button type="primary">Button</Button>
</div>
);
}
}
export default App;