antd.macro

A babel macro that helps you import antd's style.

Usage no npm install needed!

<script type="module">
  import antdMacro from 'https://cdn.skypack.dev/antd.macro';
</script>

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?

  1. It's explicitly.
  2. It's antd-specific.
  3. It can be used in CRA directly without ejecting.
  4. It keeps your import statements, since webpack already has tree-shaking, it's unnecessary to import a component from a specific location.

License

MIT