README
antd.macro
A babel macro that helps you import antd's style.
Installation
$ npm install antd.macro --save-dev
Usage
import { Button } from 'antd.macro';
Transforms to:
import 'antd/es/button/css';
import { Button } from 'antd';
Config
Create a babel-plugin-macros config file.
// babel-plugin-macros.config.js
module.exports = {
antd: {
style: 'less' // default is 'css',
},
}
What's the difference with babel-plugin-import?
- It's explicitly.
- It's antd-specific.
- It can be used in CRA directly without ejecting.
- It keeps your import statements, since webpack already has tree-shaking, it's unnecessary to import a component from a specific location.