@@ -13,20 +13,20 @@ const fs = require('fs');
1313const url = require ( 'url' ) ;
1414
1515// 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
1717const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
1818const resolveApp = relativePath => path . resolve ( appDirectory , relativePath ) ;
1919
2020const envPublicUrl = process . env . PUBLIC_URL ;
2121
22- function ensureSlash ( path , needsSlash ) {
23- const hasSlash = path . endsWith ( '/' ) ;
22+ function ensureSlash ( inputPath , needsSlash ) {
23+ const hasSlash = inputPath . endsWith ( '/' ) ;
2424 if ( hasSlash && ! needsSlash ) {
25- return path . substr ( path , path . length - 1 ) ;
25+ return inputPath . substr ( 0 , inputPath . length - 1 ) ;
2626 } else if ( ! hasSlash && needsSlash ) {
27- return `${ path } /` ;
27+ return `${ inputPath } /` ;
2828 } else {
29- return path ;
29+ return inputPath ;
3030 }
3131}
3232
@@ -41,14 +41,15 @@ const getPublicUrl = appPackageJson =>
4141// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
4242function getServedPath ( appPackageJson ) {
4343 const publicUrl = getPublicUrl ( appPackageJson ) ;
44- const servedUrl = envPublicUrl ||
45- ( publicUrl ? url . parse ( publicUrl ) . pathname : '/' ) ;
44+ const servedUrl =
45+ envPublicUrl || ( publicUrl ? url . parse ( publicUrl ) . pathname : '/' ) ;
4646 return ensureSlash ( servedUrl , true ) ;
4747}
4848
4949// config after eject: we're in ./config/
5050module . exports = {
5151 dotenv : resolveApp ( '.env' ) ,
52+ appPath : resolveApp ( '.' ) ,
5253 appBuild : resolveApp ( 'build' ) ,
5354 appPublic : resolveApp ( 'public' ) ,
5455 appHtml : resolveApp ( 'public/index.html' ) ,
@@ -57,6 +58,7 @@ module.exports = {
5758 appSrc : resolveApp ( 'src' ) ,
5859 yarnLockFile : resolveApp ( 'yarn.lock' ) ,
5960 testsSetup : resolveApp ( 'src/setupTests.ts' ) ,
61+ proxySetup : resolveApp ( 'src/setupProxy.js' ) ,
6062 appNodeModules : resolveApp ( 'node_modules' ) ,
6163 appTsConfig : resolveApp ( 'tsconfig.json' ) ,
6264 appTsProdConfig : resolveApp ( 'tsconfig.prod.json' ) ,
@@ -80,6 +82,7 @@ module.exports = {
8082 appSrc : resolveApp ( 'src' ) ,
8183 yarnLockFile : resolveApp ( 'yarn.lock' ) ,
8284 testsSetup : resolveApp ( 'src/setupTests.ts' ) ,
85+ proxySetup : resolveApp ( 'src/setupProxy.js' ) ,
8386 appNodeModules : resolveApp ( 'node_modules' ) ,
8487 appTsConfig : resolveApp ( 'tsconfig.json' ) ,
8588 appTsProdConfig : resolveApp ( 'tsconfig.prod.json' ) ,
@@ -94,7 +97,8 @@ module.exports = {
9497
9598const ownPackageJson = require ( '../package.json' ) ;
9699const reactScriptsPath = resolveApp ( `node_modules/${ ownPackageJson . name } ` ) ;
97- const reactScriptsLinked = fs . existsSync ( reactScriptsPath ) &&
100+ const reactScriptsLinked =
101+ fs . existsSync ( reactScriptsPath ) &&
98102 fs . lstatSync ( reactScriptsPath ) . isSymbolicLink ( ) ;
99103
100104// config before publish: we're in ./packages/react-scripts/config/
113117 appSrc : resolveOwn ( 'template/src' ) ,
114118 yarnLockFile : resolveOwn ( 'template/yarn.lock' ) ,
115119 testsSetup : resolveOwn ( 'template/src/setupTests.ts' ) ,
120+ proxySetup : resolveOwn ( 'template/src/setupProxy.js' ) ,
116121 appNodeModules : resolveOwn ( 'node_modules' ) ,
117122 appTsConfig : resolveOwn ( 'template/tsconfig.json' ) ,
118123 appTsProdConfig : resolveOwn ( 'template/tsconfig.prod.json' ) ,
0 commit comments