From c84a1c01e889b81be40a138ddf75f8c76454bbef Mon Sep 17 00:00:00 2001 From: William Chargin Date: Thu, 16 Aug 2018 11:19:09 -0700 Subject: [PATCH] Remove remaining public URL logic (#686) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Now that the main functionality of #643 has been implemented, we no longer have any use for the “public URL” property. In fact, its presence is actively harmful, as it suggests that the gateway may be known before runtime, which is confusing and false. Closes #643. Test Plan: Running `yarn start` works. Building the static site works. Invoking `git grep -i 'public.\?url'` finds no matches. Also, `yarn test --full` passes. wchargin-branch: remove-public-url --- config/env.js | 7 +------ config/makeWebpackConfig.js | 2 +- config/paths.js | 27 --------------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/config/env.js b/config/env.js index e6128e3..261c035 100644 --- a/config/env.js +++ b/config/env.js @@ -59,7 +59,7 @@ process.env.NODE_PATH = (process.env.NODE_PATH || "") // injected into the application via DefinePlugin in Webpack configuration. const REACT_APP = /^REACT_APP_/i; -function getClientEnvironment(publicUrl /*: string */) { +function getClientEnvironment() { const raw = Object.keys(process.env) .filter((key) => REACT_APP.test(key)) .reduce( @@ -71,11 +71,6 @@ function getClientEnvironment(publicUrl /*: string */) { // Useful for determining whether we’re running in production mode. // Most importantly, it switches React into the correct mode. NODE_ENV: process.env.NODE_ENV || "development", - // Useful for resolving the correct path to static assets in `public`. - // For example, . - // This should only be used as an escape hatch. Normally you would put - // images into the `src` and `import` them in code to get their paths. - PUBLIC_URL: publicUrl, } ); // Stringify all values so we can feed into Webpack DefinePlugin diff --git a/config/makeWebpackConfig.js b/config/makeWebpackConfig.js index 65d9eae..312adf8 100644 --- a/config/makeWebpackConfig.js +++ b/config/makeWebpackConfig.js @@ -21,7 +21,7 @@ const getClientEnvironment = require("./env"); // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false"; // Get environment variables to inject into our app. -const env = getClientEnvironment(/* publicUrl: */ ""); +const env = getClientEnvironment(); function makeConfig(mode /*: "production" | "development" */) { return { diff --git a/config/paths.js b/config/paths.js index 1289b54..3e0045e 100644 --- a/config/paths.js +++ b/config/paths.js @@ -7,31 +7,6 @@ const fs = require("fs"); const appDirectory = fs.realpathSync(process.cwd()); const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); -const envPublicUrl = process.env.PUBLIC_URL; - -function ensureSlash(path /*: string */, needsSlash /*: bool */) { - const hasSlash = path.endsWith("/"); - if (hasSlash && !needsSlash) { - return path.substr(0, path.length - 1); - } else if (!hasSlash && needsSlash) { - return `${path}/`; - } else { - return path; - } -} - -const getPublicUrl = () => envPublicUrl || "/"; - -// We use `PUBLIC_URL` environment variable field to infer "public path" at -// which the app is served. Defaults to "/" -// Webpack needs to know it to put the right