|
| 1 | +var path = require('path'); |
| 2 | +var fs = require('fs'); |
| 3 | + |
| 4 | +// Make sure any symlinks in the project folder are resolved: |
| 5 | +// https://github.com/facebookincubator/create-react-app/issues/637 |
| 6 | +var appDirectory = fs.realpathSync(process.cwd()); |
| 7 | +function resolveApp(relativePath) { |
| 8 | + return path.resolve(appDirectory, relativePath); |
| 9 | +} |
| 10 | + |
| 11 | +// We support resolving modules according to `NODE_PATH`. |
| 12 | +// This lets you use absolute paths in imports inside large monorepos: |
| 13 | +// https://github.com/facebookincubator/create-react-app/issues/253. |
| 14 | + |
| 15 | +// It works similar to `NODE_PATH` in Node itself: |
| 16 | +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders |
| 17 | + |
| 18 | +// We will export `nodePaths` as an array of absolute paths. |
| 19 | +// It will then be used by Webpack configs. |
| 20 | +// Jest doesn’t need this because it already handles `NODE_PATH` out of the box. |
| 21 | + |
| 22 | +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. |
| 23 | +// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. |
| 24 | +// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 |
| 25 | + |
| 26 | +var nodePaths = (process.env.NODE_PATH || '') |
| 27 | + .split(process.platform === 'win32' ? ';' : ':') |
| 28 | + .filter(Boolean) |
| 29 | + .filter(folder => !path.isAbsolute(folder)) |
| 30 | + .map(resolveApp); |
| 31 | + |
| 32 | +// config after eject: we're in ./config/ |
| 33 | +module.exports = { |
| 34 | + // Changed from build to build_webpack so smart contract compilations are not overwritten. |
| 35 | + appBuild: resolveApp('build_webpack'), |
| 36 | + appPublic: resolveApp('public'), |
| 37 | + appHtml: resolveApp('public/index.html'), |
| 38 | + appIndexJs: resolveApp('src/index.js'), |
| 39 | + appPackageJson: resolveApp('package.json'), |
| 40 | + appSrc: resolveApp('src'), |
| 41 | + yarnLockFile: resolveApp('yarn.lock'), |
| 42 | + testsSetup: resolveApp('src/setupTests.js'), |
| 43 | + appNodeModules: resolveApp('node_modules'), |
| 44 | + ownNodeModules: resolveApp('node_modules'), |
| 45 | + nodePaths: nodePaths |
| 46 | +}; |
0 commit comments