- 需要安裝react-app-rewired@2.0.2-next.0
- 需要babel-plugin-import
- 擴展react里面的webpack配置,新建config-overrides.js
const {injectBabelPlugin} = require('react-app-rewired'); module.exports = function override(config, env){ config = injectBabelPlugin([ 'import', {libraryName: 'antd', libraryDirectory: 'es', style: 'css'} ], config); return config }
// 以React按需加載antd-design為例
// 這樣即可在其他JS直接import { Button } from 'antd'