When working on a project, sometimes we only use a few common Ui components, but you don’t want to include the entire ANTD package, you can try importing antD components on demand:

  1. Install antd –save NPM install antd –save NPM install antd –save NPM install antd –save
import Button from 'antd/lib/button';  // Go to antd/lib/button/index.js in node_modules and import it directly
import 'antd/lib/button/style' // Find the style reference directly under the corresponding folder
Copy the code
  1. Execute NPM run eject, which exposes the webpack configuration file, and the project will have additional config and scripts folders.

After antd and babel-plugin-import are installed, add them to the packge.json file

 "babel": {..."plugins": [["import",
                {
                    "libraryName": "antd"."style": "css"}}]]Copy the code
  1. Due to the execution of NPM run after eject project will be more than a pile of I don’t want the configuration, so you can also use the antd website written recommendation: 3 x. Ant. The design/docs/react /…