git.fiddlerwoaroof.com
config/paths.js
84348047
 const path = require("path");
 const fs = require("fs");
 const url = require("url");
ee1296bf
 
 // Make sure any symlinks in the project folder are resolved:
 // https://github.com/facebook/create-react-app/issues/637
 const appDirectory = fs.realpathSync(process.cwd());
 const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
 
 const envPublicUrl = process.env.PUBLIC_URL;
 
 function ensureSlash(inputPath, needsSlash) {
84348047
   const hasSlash = inputPath.endsWith("/");
ee1296bf
   if (hasSlash && !needsSlash) {
     return inputPath.substr(0, inputPath.length - 1);
   } else if (!hasSlash && needsSlash) {
     return `${inputPath}/`;
   } else {
     return inputPath;
   }
 }
 
 const getPublicUrl = appPackageJson =>
   envPublicUrl || require(appPackageJson).homepage;
 
 // We use `PUBLIC_URL` environment variable or "homepage" field to infer
 // "public path" at which the app is served.
 // Webpack needs to know it to put the right <script> hrefs into HTML even in
 // single-page apps that may serve index.html for nested URLs like /todos/42.
 // We can't use a relative path in HTML because we don't want to load something
 // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
 function getServedPath(appPackageJson) {
   const publicUrl = getPublicUrl(appPackageJson);
   const servedUrl =
84348047
     envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : "/");
ee1296bf
   return ensureSlash(servedUrl, true);
 }
 
 const moduleFileExtensions = [
84348047
   "web.mjs",
   "mjs",
   "web.js",
   "js",
   "web.ts",
   "ts",
   "web.tsx",
   "tsx",
   "json",
   "web.jsx",
   "jsx"
ee1296bf
 ];
 
 // Resolve file paths in the same order as webpack
 const resolveModule = (resolveFn, filePath) => {
   const extension = moduleFileExtensions.find(extension =>
     fs.existsSync(resolveFn(`${filePath}.${extension}`))
   );
 
   if (extension) {
     return resolveFn(`${filePath}.${extension}`);
   }
 
   return resolveFn(`${filePath}.js`);
 };
 
 // config after eject: we're in ./config/
 module.exports = {
84348047
   dotenv: resolveApp(".env"),
   appPath: resolveApp("."),
   appBuild: resolveApp("build"),
   appPublic: resolveApp("public"),
   appHtml: resolveApp("public/index.html"),
   appIndexJs: resolveModule(resolveApp, "src/index"),
   appPackageJson: resolveApp("package.json"),
   appSrc: resolveApp("src"),
   appTsConfig: resolveApp("tsconfig.json"),
   yarnLockFile: resolveApp("yarn.lock"),
   testsSetup: resolveModule(resolveApp, "src/setupTests"),
   proxySetup: resolveApp("src/setupProxy.js"),
   appNodeModules: resolveApp("node_modules"),
   publicUrl: getPublicUrl(resolveApp("package.json")),
   servedPath: getServedPath(resolveApp("package.json"))
ee1296bf
 };
 
 module.exports.moduleFileExtensions = moduleFileExtensions;