@@ -13,20 +13,20 @@ const fs = require('fs');
13
13
const url = require ( 'url' ) ;
14
14
15
15
// Make sure any symlinks in the project folder are resolved:
16
- // https://github.com/facebookincubator /create-react-app/issues/637
16
+ // https://github.com/facebook /create-react-app/issues/637
17
17
const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
18
18
const resolveApp = relativePath => path . resolve ( appDirectory , relativePath ) ;
19
19
20
20
const envPublicUrl = process . env . PUBLIC_URL ;
21
21
22
- function ensureSlash ( path , needsSlash ) {
23
- const hasSlash = path . endsWith ( '/' ) ;
22
+ function ensureSlash ( inputPath , needsSlash ) {
23
+ const hasSlash = inputPath . endsWith ( '/' ) ;
24
24
if ( hasSlash && ! needsSlash ) {
25
- return path . substr ( path , path . length - 1 ) ;
25
+ return inputPath . substr ( 0 , inputPath . length - 1 ) ;
26
26
} else if ( ! hasSlash && needsSlash ) {
27
- return `${ path } /` ;
27
+ return `${ inputPath } /` ;
28
28
} else {
29
- return path ;
29
+ return inputPath ;
30
30
}
31
31
}
32
32
@@ -41,14 +41,15 @@ const getPublicUrl = appPackageJson =>
41
41
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
42
42
function getServedPath ( appPackageJson ) {
43
43
const publicUrl = getPublicUrl ( appPackageJson ) ;
44
- const servedUrl = envPublicUrl ||
45
- ( publicUrl ? url . parse ( publicUrl ) . pathname : '/' ) ;
44
+ const servedUrl =
45
+ envPublicUrl || ( publicUrl ? url . parse ( publicUrl ) . pathname : '/' ) ;
46
46
return ensureSlash ( servedUrl , true ) ;
47
47
}
48
48
49
49
// config after eject: we're in ./config/
50
50
module . exports = {
51
51
dotenv : resolveApp ( '.env' ) ,
52
+ appPath : resolveApp ( '.' ) ,
52
53
appBuild : resolveApp ( 'build' ) ,
53
54
appPublic : resolveApp ( 'public' ) ,
54
55
appHtml : resolveApp ( 'public/index.html' ) ,
@@ -57,6 +58,7 @@ module.exports = {
57
58
appSrc : resolveApp ( 'src' ) ,
58
59
yarnLockFile : resolveApp ( 'yarn.lock' ) ,
59
60
testsSetup : resolveApp ( 'src/setupTests.ts' ) ,
61
+ proxySetup : resolveApp ( 'src/setupProxy.js' ) ,
60
62
appNodeModules : resolveApp ( 'node_modules' ) ,
61
63
appTsConfig : resolveApp ( 'tsconfig.json' ) ,
62
64
appTsProdConfig : resolveApp ( 'tsconfig.prod.json' ) ,
@@ -80,6 +82,7 @@ module.exports = {
80
82
appSrc : resolveApp ( 'src' ) ,
81
83
yarnLockFile : resolveApp ( 'yarn.lock' ) ,
82
84
testsSetup : resolveApp ( 'src/setupTests.ts' ) ,
85
+ proxySetup : resolveApp ( 'src/setupProxy.js' ) ,
83
86
appNodeModules : resolveApp ( 'node_modules' ) ,
84
87
appTsConfig : resolveApp ( 'tsconfig.json' ) ,
85
88
appTsProdConfig : resolveApp ( 'tsconfig.prod.json' ) ,
@@ -94,7 +97,8 @@ module.exports = {
94
97
95
98
const ownPackageJson = require ( '../package.json' ) ;
96
99
const reactScriptsPath = resolveApp ( `node_modules/${ ownPackageJson . name } ` ) ;
97
- const reactScriptsLinked = fs . existsSync ( reactScriptsPath ) &&
100
+ const reactScriptsLinked =
101
+ fs . existsSync ( reactScriptsPath ) &&
98
102
fs . lstatSync ( reactScriptsPath ) . isSymbolicLink ( ) ;
99
103
100
104
// config before publish: we're in ./packages/react-scripts/config/
113
117
appSrc : resolveOwn ( 'template/src' ) ,
114
118
yarnLockFile : resolveOwn ( 'template/yarn.lock' ) ,
115
119
testsSetup : resolveOwn ( 'template/src/setupTests.ts' ) ,
120
+ proxySetup : resolveOwn ( 'template/src/setupProxy.js' ) ,
116
121
appNodeModules : resolveOwn ( 'node_modules' ) ,
117
122
appTsConfig : resolveOwn ( 'template/tsconfig.json' ) ,
118
123
appTsProdConfig : resolveOwn ( 'template/tsconfig.prod.json' ) ,
0 commit comments