1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
7 const path = require('path');
8 const fs = require('fs');
9 const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
11 // Make sure any symlinks in the project folder are resolved:
12 // https://github.com/facebook/create-react-app/issues/637
13 const appDirectory = fs.realpathSync(process.cwd());
14 const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
16 // We use `PUBLIC_URL` environment variable or "homepage" field to infer
17 // "public path" at which the app is served.
18 // webpack needs to know it to put the right <script> hrefs into HTML even in
19 // single-page apps that may serve index.html for nested URLs like /todos/42.
20 // We can't use a relative path in HTML because we don't want to load something
21 // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
22 const publicUrlOrPath = getPublicUrlOrPath(
23 process.env.NODE_ENV === 'development',
24 require(resolveApp('package.json')).homepage,
25 process.env.PUBLIC_URL
28 const buildPath = process.env.BUILD_PATH || 'build';
30 const moduleFileExtensions = [
44 // Resolve file paths in the same order as webpack
45 const resolveModule = (resolveFn, filePath) => {
46 const extension = moduleFileExtensions.find(extension =>
47 fs.existsSync(resolveFn(`${filePath}.${extension}`))
51 return resolveFn(`${filePath}.${extension}`);
54 return resolveFn(`${filePath}.js`);
57 // config after eject: we're in ./config/
59 dotenv: resolveApp('.env'),
60 appPath: resolveApp('.'),
61 appBuild: resolveApp(buildPath),
62 appPublic: resolveApp('public'),
63 appHtml: resolveApp('public/index.html'),
64 appIndexJs: resolveModule(resolveApp, 'src/index'),
65 appPackageJson: resolveApp('package.json'),
66 appSrc: resolveApp('src'),
67 appTsConfig: resolveApp('tsconfig.json'),
68 appJsConfig: resolveApp('jsconfig.json'),
69 yarnLockFile: resolveApp('yarn.lock'),
70 testsSetup: resolveModule(resolveApp, 'src/setupTests'),
71 proxySetup: resolveApp('src/setupProxy.js'),
72 appNodeModules: resolveApp('node_modules'),
73 appWebpackCache: resolveApp('node_modules/.cache'),
74 appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
75 swSrc: resolveModule(resolveApp, 'src/service-worker'),
81 module.exports.moduleFileExtensions = moduleFileExtensions;