Skip to content
This repository was archived by the owner on Oct 3, 2019. It is now read-only.

dodrio/react-app-rewire-antd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-app-rewire-antd

Standard - JavaScript Style Guide Dependency Status DevDependency Status NPM Downloads

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:

License

MIT © m31271n

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors