Skip to content

Commit a547edb

Browse files
committed
add support for cra-1.x.x
1 parent b7380bb commit a547edb

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

bin/monkey-react-scripts.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
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

66
switch (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;

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",
@@ -14,6 +14,9 @@
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
}

scripts/build.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
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';
45
process.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

1314
if (fs.existsSync(webpackMonkeyPath)) {
1415
console.log(chalk.yellow('WARNING! You are using modified webpack config!'));

scripts/start.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
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';
45
process.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

1314
if (fs.existsSync(webpackMonkeyPath)) {
1415
console.log(chalk.yellow('WARNING! You are using modified webpack config!'));

snippets/cra-1.x.x.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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.

0 commit comments

Comments
 (0)