paths.js 1.8 KB

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