forked from stereobooster/react-snap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.js
executable file
·48 lines (42 loc) · 1.05 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
const url = require("url");
const { run } = require("./index.js");
const {
reactSnap,
homepage,
devDependencies,
dependencies
} = require(`${process.cwd()}/package.json`);
const publicUrl = process.env.PUBLIC_URL || homepage;
const reactScriptsVersion = parseInt(
(devDependencies && devDependencies["react-scripts"])
|| (dependencies && dependencies["react-scripts"])
);
let fixWebpackChunksIssue;
switch (reactScriptsVersion) {
case 1:
fixWebpackChunksIssue = "CRA1";
break;
case 2:
fixWebpackChunksIssue = "CRA2";
break;
}
const parcel = Boolean(
(devDependencies && devDependencies["parcel-bundler"])
|| (dependencies && dependencies["parcel-bundler"])
);
if (parcel) {
if (fixWebpackChunksIssue) {
console.log("Detected both Parcel and CRA. Fixing chunk names for CRA!")
} else {
fixWebpackChunksIssue = "Parcel";
}
}
run({
publicPath: publicUrl ? url.parse(publicUrl).pathname : "/",
fixWebpackChunksIssue,
...reactSnap
}).catch(error => {
console.error(error);
process.exit(1);
});