https://github.com/sylvanasgone/react-app-rewire-antd-starter-config
A config for using react-app-rewired v2+ with Antd, react-hot-loader, PostCSS and more
https://github.com/sylvanasgone/react-app-rewire-antd-starter-config
Last synced: 2 months ago
JSON representation
A config for using react-app-rewired v2+ with Antd, react-hot-loader, PostCSS and more
- Host: GitHub
- URL: https://github.com/sylvanasgone/react-app-rewire-antd-starter-config
- Owner: SylvanasGone
- License: mit
- Created: 2019-12-17T08:11:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T12:53:56.000Z (over 2 years ago)
- Last Synced: 2025-03-18T12:59:51.654Z (2 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-app-rewire-antd-starter-config
An override-config for using react-app-rewired 2.0+ with Antd, react-hot-loader, PostCSS and more
基于 react-app-rewired 2.0+ 的 antd 项目初始化配置
⚠️ This config can NOT fit the version of create-react-app lower than 2.0
## Motivation
After rewiring a create-react-app project, we have to ovrride much config to meet our customized needs. Painfully, the same work is repeated every time when you initialize a rewired project. Thus, why not importing a ready-to-go config directly?
## Features
- support react-hot-loader
- support CSS Modules(enable CSS modules without any special extension)
- support all features of postcss-preset-env(stage: 0)
- add support for Antd and Lodash to import components on demand by default
- add support for using .eslintrc.json file to customize eslint by
default
- add support for using '@' as root directory by default## Preparation
1 ) Install create-react-app 2.x / 3.x
2 ) Install react-app-rewired 2.x
3 ) Install react-app-rewire-hot-loader
```sh
yarn add -D react-app-rewire-hot-loader# If you don't already, you also need
yarn add react-hot-loader
```## Install
```sh
yarn add -D react-app-rewire-antd-starter-config
```## Usage
In the config-overrides.js of the root of your project you created for react-app-rewired add this code:
```js
const rewireDefaultConfig = require('react-app-rewire-antd-starter-config')module.exports = (config, env) => {
// ...other rewires
return rewireDefaultConfig(config, env)
}
```E.g.
```jsx
// CSS modules without extension
import * as styles from './example.css'// import on demand
import { Button, Table } from 'antd'
import { cloneDeep, pickBy } from 'lodash'
// use '@' as root directory
import Example from '@/Components/Example'const TestComponent = () => (
Title
/* ... */
)
```Enjoy coding!
## LICENSE
MIT