|
| 1 | +// @remove-on-eject-begin |
1 | 2 | /**
|
2 | 3 | * Copyright (c) 2015-present, Facebook, Inc.
|
3 | 4 | * All rights reserved.
|
|
6 | 7 | * LICENSE file in the root directory of this source tree. An additional grant
|
7 | 8 | * of patent rights can be found in the PATENTS file in the same directory.
|
8 | 9 | */
|
9 |
| - |
10 |
| -// TODO: we can split this file into several files (pre-eject, post-eject, test) |
11 |
| -// and use those instead. This way we don't need to branch here. |
| 10 | +// @remove-on-eject-end |
12 | 11 |
|
13 | 12 | var path = require('path');
|
14 | 13 |
|
15 |
| -// True after ejecting, false when used as a dependency |
16 |
| -var isEjected = ( |
17 |
| - path.resolve(path.join(__dirname, '..')) === |
18 |
| - path.resolve(process.cwd()) |
19 |
| -); |
| 14 | +function resolveApp(relativePath) { |
| 15 | + return path.resolve(relativePath); |
| 16 | +} |
20 | 17 |
|
21 |
| -// Are we developing create-react-app locally? |
22 |
| -var isInCreateReactAppSource = ( |
23 |
| - process.argv.some(arg => arg.indexOf('--debug-template') > -1) |
24 |
| -); |
| 18 | +// config after eject: we're in ./config/ |
| 19 | +module.exports = { |
| 20 | + appBuild: resolveApp('build'), |
| 21 | + appHtml: resolveApp('index.html'), |
| 22 | + appPackageJson: resolveApp('package.json'), |
| 23 | + appSrc: resolveApp('src'), |
| 24 | + appNodeModules: resolveApp('node_modules'), |
| 25 | + ownNodeModules: resolveApp('node_modules') |
| 26 | +}; |
25 | 27 |
|
| 28 | +// @remove-on-eject-begin |
26 | 29 | function resolveOwn(relativePath) {
|
27 | 30 | return path.resolve(__dirname, relativePath);
|
28 | 31 | }
|
| 32 | +// config before eject: we're in ./node_modules/react-scripts/config/ |
| 33 | +module.exports = { |
| 34 | + appBuild: resolveApp('build'), |
| 35 | + appHtml: resolveApp('index.html'), |
| 36 | + appPackageJson: resolveApp('package.json'), |
| 37 | + appSrc: resolveApp('src'), |
| 38 | + appNodeModules: resolveApp('node_modules'), |
| 39 | + // this is empty with npm3 but node resolution searches higher anyway: |
| 40 | + ownNodeModules: resolveOwn('../node_modules') |
| 41 | +}; |
| 42 | +// @remove-on-eject-end |
29 | 43 |
|
30 |
| -function resolveApp(relativePath) { |
31 |
| - return path.resolve(relativePath); |
32 |
| -} |
33 |
| - |
34 |
| -if (isInCreateReactAppSource) { |
35 |
| - // create-react-app development: we're in ./config/ |
36 |
| - module.exports = { |
37 |
| - appBuild: resolveOwn('../build'), |
38 |
| - appHtml: resolveOwn('../template/index.html'), |
39 |
| - appPackageJson: resolveOwn('../package.json'), |
40 |
| - appStatic: resolveOwn('../template/static'), |
41 |
| - appSrc: resolveOwn('../template/src'), |
42 |
| - appNodeModules: resolveOwn('../node_modules'), |
43 |
| - ownNodeModules: resolveOwn('../node_modules') |
44 |
| - }; |
45 |
| -} else if (!isEjected) { |
46 |
| - // before eject: we're in ./node_modules/react-scripts/config/ |
47 |
| - module.exports = { |
48 |
| - appBuild: resolveApp('build'), |
49 |
| - appHtml: resolveApp('index.html'), |
50 |
| - appPackageJson: resolveApp('package.json'), |
51 |
| - appStatic: resolveApp('static'), |
52 |
| - appSrc: resolveApp('src'), |
53 |
| - appNodeModules: resolveApp('node_modules'), |
54 |
| - // this is empty with npm3 but node resolution searches higher anyway: |
55 |
| - ownNodeModules: resolveOwn('../node_modules') |
56 |
| - }; |
57 |
| -} else { |
58 |
| - // after eject: we're in ./config/ |
59 |
| - module.exports = { |
60 |
| - appBuild: resolveApp('build'), |
61 |
| - appHtml: resolveApp('index.html'), |
62 |
| - appPackageJson: resolveApp('package.json'), |
63 |
| - appStatic: resolveApp('static'), |
64 |
| - appSrc: resolveApp('src'), |
65 |
| - appNodeModules: resolveApp('node_modules'), |
66 |
| - ownNodeModules: resolveApp('node_modules') |
67 |
| - }; |
68 |
| -} |
| 44 | +// @remove-on-publish-begin |
| 45 | +module.exports = { |
| 46 | + appBuild: resolveOwn('../build'), |
| 47 | + appHtml: resolveOwn('../template/index.html'), |
| 48 | + appPackageJson: resolveOwn('../package.json'), |
| 49 | + appSrc: resolveOwn('../template/src'), |
| 50 | + appNodeModules: resolveOwn('../node_modules'), |
| 51 | + ownNodeModules: resolveOwn('../node_modules') |
| 52 | +}; |
| 53 | +// @remove-on-publish-end |
0 commit comments