npm.io
1.0.3 • Published 8 years ago

react-app-rewire-antd

Licence
MIT
Version
1.0.3
Deps
4
Vulns
0
Weekly
0
Stars
3

react-app-rewire-antd

Standard - JavaScript Style Guide Dependency Status DevDependency Status NPM Downloads Travis Build Status

Load antd into your create-react-app app via react-app-rewired.

Install

$ npm install react-app-rewire-antd

Usage

First, edit config-overrides.js:

/* config-overrides.js */
const rewireAntd = require('react-app-rewire-antd')

module.exports = function override(config, env) {

  // ...

  config = rewireAntd({
    '@primary-color': 'rgb(97,43,189)'
  })(config, env)

  // ...

  return config
}

Then, use antd as normal module. antd's components related JS and CSS will be imported on demand:

import React, { Component } from 'react';
import { Button } from 'antd'; // only import Button related JS and CSS

class App extends Component {
  render() {
    return (
      <div>
        <Button type="primary">Button</Button>
      </div>
    );
  }
}

export default App;

That's it !

API

rewireAntd(options)
  • options
    • type: Object
    • default value: {}
    • description: key-value pairs in options will be used to replace antd's default variables.

How it works

Thanks to the power of following packages:

  • react-app-rewired
  • react-app-rewire-less
  • babel-plugin-import

And following packages:

And official ant-design docs:


Made with by m31271n