Installation babel-plugin-import plug-ins. A method selected from the following two, can implement on-demand loading of antd .
First, the configuration file webpack.config.js
{ test: /.jsx?$/, exclude: /(node_modules|bower_components)/, use: [{ loader: 'babel-loader' }], options: { "plugins": [ [ "import", { "libraryName": "antd", "style": true } ] ] } }
Second, the configuration file babelrc
{ "presets": ["env", "react"], "plugins": [ "transform-runtime", "transform-object-rest-spread", [ "import", { "libraryName": "antd", "style": true } ] ] }