@@ -66,7 +66,7 @@ snippets:
66
66
67
67
- ` addPlugin `
68
68
- ` findRule `
69
- - ` addBabelPlugins `
69
+ - ` findBabelRule `
70
70
71
71
## Example
72
72
@@ -87,6 +87,27 @@ module.exports = function(webpackConfig, isDevelopment) {
87
87
88
88
Also, you can find complete examples at [ monkey-react-scripts-example] repo
89
89
90
+ ### Enable ` .babelrc `
91
+
92
+ The ` .babelrc ` file is enabled for tests if you have ` webpack.monkey.js ` file. also, you can enable ` .babelrc ` for build and start:
93
+
94
+ - edit ` webpack.monkey.js ` like this (copy ` findRule ` , ` findBabelRule ` from [ snippets] ( snippets/cra-2.x.x.md ) ):
95
+
96
+ ``` js
97
+ function findRule (webpackConfig , callback ) {
98
+ /* snippet codes */
99
+ }
100
+
101
+ function findBabelRule (webpackConfig , callback ) {
102
+ /* snippet codes */
103
+ }
104
+
105
+ module .exports = function (webpackConfig , isDevelopment ) {
106
+ const babelRule = findBabelRule (webpackConfig);
107
+ babelRule .options .babelrc = true ;
108
+ };
109
+ ```
110
+
90
111
### Webpack Visualizer
91
112
92
113
I love visualization so, I add [ webpack-visualizer-plugin] [ webpack-visualizer ] to my project
@@ -137,22 +158,12 @@ If you love decorators, you can add decorator support:
137
158
npm install --save-dev @babel/plugin-proposal-decorators
138
159
```
139
160
140
- - edit ` webpack.monkey.js ` like this (copy ` findRule ` , ` addBabelPlugins ` from [ snippets ] ( snippets/cra-2.x.x.md ) ) :
161
+ - edit ` .babelrc ` like this:
141
162
142
- ``` js
143
- function findRule (webpackConfig , callback ) {
144
- /* snippet codes */
145
- }
146
-
147
- function addBabelPlugins (webpackConfig , plugins ) {
148
- /* snippet codes */
163
+ ``` json
164
+ {
165
+ "plugins" : [[" @babel/plugin-proposal-decorators" , { "legacy" : true }]]
149
166
}
150
-
151
- module .exports = function (webpackConfig , isDevelopment ) {
152
- addBabelPlugins (webpackConfig, [
153
- [" @babel/plugin-proposal-decorators" , { legacy: true }]
154
- ]);
155
- };
156
167
```
157
168
158
169
related issues: [ #107 ] [ 107 ] , [ #167 ] [ 167 ] , [ #214 ] [ 214 ] , [ #309 ] [ 309 ] , [ #411 ] [ 411 ] , [ #1357 ] [ 1357 ]
@@ -165,12 +176,12 @@ related issues: [#107][107], [#167][167], [#214][214], [#309][309], [#411][411],
165
176
yarn add --dev babel-plugin-relay
166
177
```
167
178
168
- - edit ` webpack.monkey.js `
179
+ - edit ` .babelrc ` like this:
169
180
170
- ``` js
171
- module . exports = function ( webpackConfig , isDevelopment ) {
172
- addBabelPlugins (webpackConfig, [" relay" ]);
173
- };
181
+ ``` json
182
+ {
183
+ "plugins" : [" relay" ]
184
+ }
174
185
```
175
186
176
187
and continue [ relay documentation] [ relay-setup ] steps.
0 commit comments