babel-plugin-override-antd-prefix-cls

0.0.1 • Public • Published

Read babel plugin handbook -> https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md

Try http://astexplorer.net/#/Pcw9baefXI for a visual understanding.

babel-plugin-boilerplate

Add a description for the plugin here

Example

In

import { Button } from 'antd';
import React from 'react';

class App extends React.Component {
  render() {
    <Button> hello world </Button>
  }
}

Out

import 'antd/lib/button/style';
import _Button from 'antd/lib/button';
_Button.defaultProps = Object.assign(_Button.defaultProps || {}, {
  prefixCls: (_Button.defaultProps.prefixCls || '').replace(/ant/g, 'deer')
});

import React from 'react';

class App extends React.Component {
  render() {
    React.createElement(
      _Button,
      null,
      ' hello world '
    );
  }
}

Installation

$ npm install babel-plugin-override-antd-prefix-cls

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["babel-plugin-override-antd-prefix-cls"]
}

Via CLI

$ babel --plugins babel-plugin-override-antd-prefix-cls script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["babel-plugin-override-antd-prefix-cls"]
});

Package Sidebar

Install

npm i babel-plugin-override-antd-prefix-cls

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • raohai