@@ -42,7 +42,7 @@ module.exports = function (webpackConfig, isDevelopment) {
4242 "scripts": {
4343 "start": "monkey-react-scripts start",
4444 "build": "monkey-react-scripts build",
45- "test": "monkey-react-scripts test --env=jsdom "
45+ "test": "monkey-react-scripts test"
4646 }
4747```
4848
@@ -52,13 +52,12 @@ I suggest you see [scripts](scripts) and [bin](bin) folders. (less than 100 line
5252Note: returned value of ` require ` function is mutable. so you can mutate that before real build/start script.
5353
5454## Snippets
55- You can use [ snippets] ( snippets/cra-1 .x.x.md ) if you want.
55+ You can use [ snippets] ( snippets/cra-2 .x.x.md ) if you want.
5656
5757snippets:
5858- ` addPlugin `
5959- ` findRule `
6060- ` addBabelPlugins `
61- - ` addRule `
6261
6362## Example
6463Before use examples, you should know what happens inside react-scripts webpack config.
@@ -106,33 +105,28 @@ build
106105├── index.html
107106├── static
108107│ ├── css
109- │ │ ├── main.9a0fe4f1.css
110- │ │ └── main.9a0fe4f1.css.map
111108│ ├── js
112- │ │ ├── main.373f9afc.js
113- │ │ └── main.373f9afc.js.map
114109│ └── media
115- │ └── logo.5d5d9eef.svg
116110└── stats.html <-- new file
117111```
118112### Decorator support
119113If you love decorators, you can add decorator support:
120114- install decorator plugin
121115```
122- npm install --save-dev babel- plugin-transform -decorators-legacy
116+ npm install --save-dev @ babel/ plugin-proposal -decorators
123117```
124- - edit ` webpack.monkey.js ` like this (copy ` findRule ` , ` addBabelPlugins ` from [ snippets] ( snippets/cra-1 .x.x.md ) ):
118+ - edit ` webpack.monkey.js ` like this (copy ` findRule ` , ` addBabelPlugins ` from [ snippets] ( snippets/cra-2 .x.x.md ) ):
125119``` js
126120function findRule (webpackConfig , callback ) {
127121 /* snippet codes */
128122}
129123
130124function addBabelPlugins (webpackConfig , plugins ) {
131- /* snippet codes */
125+ /* snippet codes */
132126}
133127
134128module .exports = function (webpackConfig , isDevelopment ) {
135- addBabelPlugins (webpackConfig, [' transform-decorators- legacy' ]);
129+ addBabelPlugins (webpackConfig, [[ " @babel/plugin-proposal-decorators " , { legacy: true }] ]);
136130};
137131```
138132related issues: [ #107 ] [ 107 ] , [ #167 ] [ 167 ] , [ #214 ] [ 214 ] , [ #309 ] [ 309 ] , [ #411 ] [ 411 ] , [ #1357 ] [ 1357 ]
@@ -156,52 +150,17 @@ if you are using relay classic you can see [old readme][old-relay-support] and g
156150
157151related issues: [ #462 ] [ 462 ] , [ #662 ] [ 662 ] , [ #900 ] [ 900 ]
158152
159- ### scss support
160- - install ` node-sass ` and ` sass-loader ` :
161-
162- ```
163- npm install --save-dev node-sass sass-loader
164- ```
165-
166- - edit ` webpack.monkey.js ` like this:
167- ``` js
168- /* copy findRule, addRule from snippets */
169- module .exports = function (webpackConfig , isDevelopment ) {
170- // find css rule
171- const cssRule = findRule (webpackConfig, (rule ) => {
172- return (' ' + rule .test === ' ' + / \. css$ / )
173- });
174- const cssLoaders = isDevelopment ? cssRule .use : cssRule .loader ;
175-
176- const postCssLoader = cssLoaders[cssLoaders .length - 1 ];
177- postCssLoader .options .sourceMap = true ; // add source option to postcss
178-
179- // add sass support
180- const sassLoader = {loader: require .resolve (' sass-loader' ), options: {sourceMap: true }};
181- const sassLoaders = cssLoaders .concat (sassLoader);
182-
183- const sassRule = {
184- test: / \. scss$ / ,
185- [isDevelopment ? ' use' : ' loader' ]: sassLoaders,
186- };
187-
188- addRule (webpackConfig, sassRule)
189- };
190- ```
191- similar code for less or stylus.
192-
193- related issues: [ #78 ] [ 78 ] , [ #115 ] [ 115 ] , [ #351 ] [ 351 ] , [ #412 ] [ 412 ] , [ #1509 ] [ 1509 ] , [ #1639 ] [ 1639 ]
194-
195153## postcss config
196154If you want to change postcss config you can use this code.
197155``` js
198156 // add rtl css support
157+ // find postCssLoader
199158 const postCssFunction = postCssLoader .options .plugins
200159 postCssLoader .options .plugins = () => {
201160 return [... postCssFunction (), require (' postcss-inline-rtl' )]
202161 }
203162```
204-
163+ you can find more detail in [ this file ] [ css-patch ]
205164## TODOs
206165
207166- [ ] customize test runner (jest)
@@ -227,6 +186,7 @@ If you want to change postcss config you can use this code.
227186[ relay-setup ] : https://facebook.github.io/relay/docs/en/installation-and-setup.html
228187[ monkey-react-scripts-example ] : https://github.com/monkey-patches/monkey-react-scripts-example
229188[ old-relay-support ] : https://github.com/monkey-patches/monkey-react-scripts/blob/b7380bbb873d637cdd6cf911de9f696b90b608fe/README.md#relay-support
189+ [ css-patch ] : https://github.com/monkey-patches/monkey-react-scripts-example/blob/d759030325ca2d638b1ea0dd44e51655b88d5022/webpack-helpers/cssPatch.js
230190
231191[ 107 ] : https://github.com/facebookincubator/create-react-app/issues/107
232192[ 167 ] : https://github.com/facebookincubator/create-react-app/issues/167
@@ -238,10 +198,3 @@ If you want to change postcss config you can use this code.
238198[ 462 ] : https://github.com/facebookincubator/create-react-app/issues/462
239199[ 662 ] : https://github.com/facebookincubator/create-react-app/pull/662
240200[ 900 ] : https://github.com/facebookincubator/create-react-app/issues/900
241-
242- [ 78 ] : https://github.com/facebookincubator/create-react-app/issues/78
243- [ 115 ] : https://github.com/facebookincubator/create-react-app/pull/115
244- [ 351 ] : https://github.com/facebookincubator/create-react-app/issues/351
245- [ 412 ] : https://github.com/facebookincubator/create-react-app/pull/412
246- [ 1509 ] : https://github.com/facebookincubator/create-react-app/pull/1509
247- [ 1639 ] : https://github.com/facebookincubator/create-react-app/issues/1639
0 commit comments