@@ -66,7 +66,7 @@ snippets:
6666
6767- ` addPlugin `
6868- ` findRule `
69- - ` addBabelPlugins `
69+ - ` findBabelRule `
7070
7171## Example
7272
@@ -87,6 +87,27 @@ module.exports = function(webpackConfig, isDevelopment) {
8787
8888Also, you can find complete examples at [ monkey-react-scripts-example] repo
8989
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+
90111### Webpack Visualizer
91112
92113I 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:
137158npm install --save-dev @babel/plugin-proposal-decorators
138159```
139160
140- - edit ` webpack.monkey.js ` like this (copy ` findRule ` , ` addBabelPlugins ` from [ snippets ] ( snippets/cra-2.x.x.md ) ) :
161+ - edit ` .babelrc ` like this:
141162
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 }]]
149166}
150-
151- module .exports = function (webpackConfig , isDevelopment ) {
152- addBabelPlugins (webpackConfig, [
153- [" @babel/plugin-proposal-decorators" , { legacy: true }]
154- ]);
155- };
156167```
157168
158169related 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],
165176yarn add --dev babel-plugin-relay
166177```
167178
168- - edit ` webpack.monkey.js `
179+ - edit ` .babelrc ` like this:
169180
170- ``` js
171- module . exports = function ( webpackConfig , isDevelopment ) {
172- addBabelPlugins (webpackConfig, [" relay" ]);
173- };
181+ ``` json
182+ {
183+ "plugins" : [" relay" ]
184+ }
174185```
175186
176187and continue [ relay documentation] [ relay-setup ] steps.
0 commit comments