File tree Expand file tree Collapse file tree 5 files changed +36
-23
lines changed Expand file tree Collapse file tree 5 files changed +36
-23
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- var spawn = require ( 'cross-spawn ' ) ;
3- var script = process . argv [ 2 ] ;
4- var args = process . argv . slice ( 3 ) ;
2+ const spawn = require ( 'react-dev-utils/crossSpawn ' ) ;
3+ const script = process . argv [ 2 ] ;
4+ const args = process . argv . slice ( 3 ) ;
55
66switch ( script ) {
77 case 'build' :
88 case 'start' :
9- case 'test' :
10- var result = spawn . sync (
9+ case 'test' : {
10+ const result = spawn . sync (
1111 'node' ,
1212 [ require . resolve ( '../scripts/' + script ) ] . concat ( args ) ,
1313 { stdio : 'inherit' }
1414 ) ;
1515 if ( result . signal ) {
16- if ( result . signal == 'SIGKILL' ) {
16+ if ( result . signal === 'SIGKILL' ) {
1717 console . log (
1818 'The build failed because the process exited too early. ' +
1919 'This probably means the system ran out of memory or someone called ' +
2020 '`kill -9` on the process.'
2121 ) ;
22- } else if ( result . signal == 'SIGTERM' ) {
22+ } else if ( result . signal === 'SIGTERM' ) {
2323 console . log (
2424 'The build failed because the process exited too early. ' +
2525 'Someone might have called `kill` or `killall`, or the system could ' +
@@ -30,6 +30,7 @@ switch (script) {
3030 }
3131 process . exit ( result . status ) ;
3232 break ;
33+ }
3334 default :
3435 console . log ( 'Unknown script "' + script + '".' ) ;
3536 break ;
Original file line number Diff line number Diff line change 11{
22 "name" : " monkey-react-scripts" ,
3- "version" : " 0.0.5 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " Monkey react script runner" ,
55 "main" : " index.js" ,
66 "repository" : " git@github.com:monkey-patches/monkey-react-scripts.git" ,
1414 "monkey-react-scripts" : " ./bin/monkey-react-scripts.js"
1515 },
1616 "peerDependencies" : {
17- "react-scripts" : " >=0.9.0"
17+ "react-scripts" : " >=1.0.0"
18+ },
19+ "dependencies" : {
20+ "react-dev-utils" : " ^3.0.2"
1821 }
1922}
Original file line number Diff line number Diff line change 1- var fs = require ( 'fs' ) ;
2- var path = require ( 'path' ) ;
1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
33
4+ process . env . BABEL_ENV = 'production' ;
45process . env . NODE_ENV = 'production' ;
56
6- require ( 'dotenv' ) . config ( { silent : true } ) ;
7+ require ( 'react-scripts/ config/env' ) ;
78
8- var chalk = require ( 'chalk' ) ;
9- var appPath = require ( 'react-scripts/config/paths' ) . appPath ;
10- var webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
11- var webpackConfig = require ( 'react-scripts/config/webpack.config.prod' ) ;
9+ const chalk = require ( 'chalk' ) ;
10+ const appPath = require ( 'react-scripts/config/paths' ) . appPath ;
11+ const webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
12+ const webpackConfig = require ( 'react-scripts/config/webpack.config.prod' ) ;
1213
1314if ( fs . existsSync ( webpackMonkeyPath ) ) {
1415 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
Original file line number Diff line number Diff line change 1- var fs = require ( 'fs' ) ;
2- var path = require ( 'path' ) ;
1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
33
4+ process . env . BABEL_ENV = 'development' ;
45process . env . NODE_ENV = 'development' ;
56
6- require ( 'dotenv' ) . config ( { silent : true } ) ;
7+ require ( 'react-scripts/ config/env' ) ;
78
8- var chalk = require ( 'chalk' ) ;
9- var appPath = require ( 'react-scripts/config/paths' ) . appPath ;
10- var webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
11- var webpackConfig = require ( 'react-scripts/config/webpack.config.dev' ) ;
9+ const chalk = require ( 'chalk' ) ;
10+ const appPath = require ( 'react-scripts/config/paths' ) . appPath ;
11+ const webpackMonkeyPath = path . resolve ( appPath , 'webpack.monkey.js' ) ;
12+ const webpackConfig = require ( 'react-scripts/config/webpack.config.dev' ) ;
1213
1314if ( fs . existsSync ( webpackMonkeyPath ) ) {
1415 console . log ( chalk . yellow ( 'WARNING! You are using modified webpack config!' ) ) ;
Original file line number Diff line number Diff line change 1+ # Code snippets for create-react-app 1.x.x
2+ useful codes you can copy and use in webpack.monkey.js file.
3+
4+ In real project I copy some of them in other file and use require function:
5+
6+ ## TODO
7+ coming soon. you can see [ snippets for cra@0.9.x ] ( cra-0.9.x.md ) and get some idea.
You can’t perform that action at this time.
0 commit comments