2018-02-18 16:13:29 +00:00
|
|
|
"use strict";
|
2018-02-17 21:28:47 +00:00
|
|
|
|
2018-02-18 16:13:29 +00:00
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
|
|
|
const url = require("url");
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
// Make sure any symlinks in the project folder are resolved:
|
|
|
|
// https://github.com/facebookincubator/create-react-app/issues/637
|
|
|
|
const appDirectory = fs.realpathSync(process.cwd());
|
2018-02-18 16:13:29 +00:00
|
|
|
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
const envPublicUrl = process.env.PUBLIC_URL;
|
|
|
|
|
|
|
|
function ensureSlash(path, needsSlash) {
|
2018-02-18 16:13:29 +00:00
|
|
|
const hasSlash = path.endsWith("/");
|
2018-02-17 21:28:47 +00:00
|
|
|
if (hasSlash && !needsSlash) {
|
|
|
|
return path.substr(path, path.length - 1);
|
|
|
|
} else if (!hasSlash && needsSlash) {
|
|
|
|
return `${path}/`;
|
|
|
|
} else {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-18 16:13:29 +00:00
|
|
|
const getPublicUrl = (appPackageJson) =>
|
2018-02-17 21:28:47 +00:00
|
|
|
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 =
|
2018-02-18 16:13:29 +00:00
|
|
|
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : "/");
|
2018-02-17 21:28:47 +00:00
|
|
|
return ensureSlash(servedUrl, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// config after eject: we're in ./config/
|
|
|
|
module.exports = {
|
2018-02-18 16:13:29 +00:00
|
|
|
dotenv: resolveApp(".env"),
|
|
|
|
appBuild: resolveApp("build"),
|
|
|
|
appPublic: resolveApp("public"),
|
|
|
|
appHtml: resolveApp("public/index.html"),
|
2018-02-27 06:32:23 +00:00
|
|
|
appIndexJs: resolveApp("src/explorer/index.js"),
|
2018-02-18 16:13:29 +00:00
|
|
|
appPackageJson: resolveApp("package.json"),
|
|
|
|
appSrc: resolveApp("src"),
|
|
|
|
yarnLockFile: resolveApp("yarn.lock"),
|
|
|
|
testsSetup: resolveApp("src/setupTests.js"),
|
|
|
|
appNodeModules: resolveApp("node_modules"),
|
|
|
|
publicUrl: getPublicUrl(resolveApp("package.json")),
|
|
|
|
servedPath: getServedPath(resolveApp("package.json")),
|
2018-03-19 05:43:23 +00:00
|
|
|
|
|
|
|
backendBuild: resolveApp("bin"),
|
|
|
|
// This object should have one key-value pair per entry point. For
|
|
|
|
// each key, the value should be the path to the entry point for the
|
|
|
|
// source file, and the key will be the filename of the bundled entry
|
|
|
|
// point within the build directory.
|
|
|
|
backendEntryPoints: {
|
|
|
|
fetchAndPrintGitHubRepo: resolveApp(
|
2018-03-19 21:31:50 +00:00
|
|
|
"src/plugins/github/bin/fetchAndPrintGitHubRepo.js"
|
2018-03-19 05:43:23 +00:00
|
|
|
),
|
|
|
|
},
|
2018-02-17 21:28:47 +00:00
|
|
|
};
|