Skip to content

Commit eb19f55

Browse files
authored
Update README.md
1 parent d64db3b commit eb19f55

File tree

1 file changed

+3
-99
lines changed

1 file changed

+3
-99
lines changed

README.md

Lines changed: 3 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
21
# Rewire Your App
32

4-
🚨CRA >=2.1.2 breaking issue [2.1.2](https://github.com/timarney/react-app-rewired/issues/343)
5-
6-
⚠️The built-in rewirers provided by this project don't support CRA 2.0 see: [2.0 Discussion](https://github.com/timarney/react-app-rewired/issues/162#issuecomment-417872507)
3+
🚨CRA >=2.1.2 breaking issue [2.1.2](https://github.com/timarney/react-app-rewired/issues/343) new release coming soon.
74

85
As of CRA 2.0 maintenance of this repo minimal, see alternatives for 2.0 supported repos.
96

10-
117
## Alternatives
128
You can try [customize-cra](https://github.com/arackaf/customize-cra) for a set of CRA 2.0 compatible rewirers,
139
or any of the alternative projects and forks that aim to support 2.0:
@@ -94,93 +90,6 @@ $ npm start
9490
$ npm run build
9591
```
9692

97-
98-
## Utilities
99-
100-
#### 1) injectBabelPlugin
101-
102-
Adding a Babel plugin can be done via the `injectBabelPlugin(pluginName, config)` function. You can also use the "rewire" packages from this repo or listed below to do common config modifications.
103-
104-
```javascript
105-
const rewireMobX = require('react-app-rewire-mobx');
106-
const rewirePreact = require('react-app-rewire-preact');
107-
const {injectBabelPlugin} = require('react-app-rewired');
108-
109-
/* config-overrides.js */
110-
module.exports = function override(config, env) {
111-
// add a plugin
112-
config = injectBabelPlugin('emotion/babel',config)
113-
114-
// use the Preact rewire
115-
if (env === "production") {
116-
console.log("⚡ Production build with Preact");
117-
config = rewirePreact(config, env);
118-
}
119-
120-
// use the MobX rewire
121-
config = rewireMobX(config,env);
122-
123-
return config;
124-
}
125-
```
126-
127-
#### 2) compose(after v1.3.4)
128-
129-
You can use this util to compose rewires.
130-
> A functional programming utility, performs `right-to-left` function composition.
131-
More detail you can see [ramda](http://ramdajs.com/docs/#compose) or [redux](http://redux.js.org/docs/api/compose.html#composefunctions)
132-
133-
Before:
134-
```javascript
135-
/* config-overrides.js */
136-
module.exports = function override(config, env) {
137-
config = rewireLess(config, env);
138-
config = rewirePreact(config, env);
139-
config = rewireMobX(config, env);
140-
141-
return config;
142-
}
143-
```
144-
After use `compose`:
145-
```javascript
146-
/* config-overrides.js */
147-
const { compose } = require('react-app-rewired');
148-
149-
module.exports = compose(
150-
rewireLess,
151-
rewirePreact,
152-
rewireMobx
153-
...
154-
)
155-
// custom config
156-
module.exports = function(config, env){
157-
const rewires = compose(
158-
rewireLess,
159-
rewirePreact,
160-
rewireMobx
161-
...
162-
);
163-
// do custom config
164-
// ...
165-
return rewires(config, env);
166-
}
167-
```
168-
Some change with rewire, if you want to add some `extra param` for `rewire`
169-
1. Optional params:
170-
you can see [react-app-rewire-less](https://github.com/timarney/react-app-rewired/blob/master/packages/react-app-rewire-less/index.js)
171-
172-
2. Required params:
173-
```javascript
174-
// rewireSome.js
175-
function createRewire(requiredParams){
176-
return function rewire(config, env){
177-
///
178-
return config
179-
}
180-
}
181-
module.exports = createRewire;
182-
```
183-
18493
## Extended Configuration Options
18594
You can set a custom path for `config-overrides.js`. If you (for instance) wanted to use a 3rd-party `config-overrides.js` that exists in `node_modules`, you could add the following to your `package.json`:
18695

@@ -191,18 +100,13 @@ You can set a custom path for `config-overrides.js`. If you (for instance) wante
191100
By default, the `config-overrides.js` file exports a single function to use when customising the webpack configuration for compiling your react app in development or production mode. It is possible to instead export an object from this file that contains up to three fields, each of which is a function. This alternative form allows you to also customise the configuration used for Jest (in testing), and for the Webpack Dev Server itself.
192101

193102
This example implementation is used to demonstrate using each of the object require functions. In the example, the functions:
194-
* use the react-app-rewire-less package to add less support to your project
195103
* have some tests run conditionally based on `.env` variables
196104
* set the https certificates to use for the Development Server, with the filenames specified in `.env` file variables.
197105
```javascript
198106
module.exports = {
199107
// The Webpack config to use when compiling your react app for development or production.
200108
webpack: function(config, env) {
201-
// ...add your webpack config customisation, rewires, etc...
202-
// Example: add less support to your app.
203-
const rewireLess = require('react-app-rewire-less');
204-
config = rewireLess(config, env);
205-
109+
// ...add your webpack config
206110
return config;
207111
},
208112
// The Jest config to use when running your jest tests - note that the normal rewires do not
@@ -328,7 +232,7 @@ If you have several custom overrides using a directory allows you to be able to
328232
#### 4) Specify config-overrides location from command line
329233
If you need to change the location of your config-overrides.js you can pass a command line option --config-overrides <path> to the react-app-rewired script.
330234

331-
# Community Maintained Rewires
235+
# Version 1.X Community Maintained Rewires (Check the plugin repo for 2.0 support)
332236

333237
## Babel plugins
334238

0 commit comments

Comments
 (0)