You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️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.
7
4
8
5
As of CRA 2.0 maintenance of this repo minimal, see alternatives for 2.0 supported repos.
9
6
10
-
11
7
## Alternatives
12
8
You can try [customize-cra](https://github.com/arackaf/customize-cra) for a set of CRA 2.0 compatible rewirers,
13
9
or any of the alternative projects and forks that aim to support 2.0:
@@ -94,93 +90,6 @@ $ npm start
94
90
$ npm run build
95
91
```
96
92
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.
> 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=functionoverride(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
-
constrewires=compose(
158
-
rewireLess,
159
-
rewirePreact,
160
-
rewireMobx
161
-
...
162
-
);
163
-
// do custom config
164
-
// ...
165
-
returnrewires(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
-
functioncreateRewire(requiredParams){
176
-
returnfunctionrewire(config, env){
177
-
///
178
-
return config
179
-
}
180
-
}
181
-
module.exports= createRewire;
182
-
```
183
-
184
93
## Extended Configuration Options
185
94
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`:
186
95
@@ -191,18 +100,13 @@ You can set a custom path for `config-overrides.js`. If you (for instance) wante
191
100
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.
192
101
193
102
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
195
103
* have some tests run conditionally based on `.env` variables
196
104
* set the https certificates to use for the Development Server, with the filenames specified in `.env` file variables.
197
105
```javascript
198
106
module.exports= {
199
107
// The Webpack config to use when compiling your react app for development or production.
200
108
webpack:function(config, env) {
201
-
// ...add your webpack config customisation, rewires, etc...
202
-
// Example: add less support to your app.
203
-
constrewireLess=require('react-app-rewire-less');
204
-
config =rewireLess(config, env);
205
-
109
+
// ...add your webpack config
206
110
return config;
207
111
},
208
112
// 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
328
232
#### 4) Specify config-overrides location from command line
329
233
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.
330
234
331
-
# Community Maintained Rewires
235
+
# Version 1.X Community Maintained Rewires (Check the plugin repo for 2.0 support)
0 commit comments