diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 0847bce51da..a4332b854dd 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -11,6 +11,7 @@ var path = require('path'); var fs = require('fs'); +var url = require('url'); // Make sure any symlinks in the project folder are resolved: // https://github.com/facebookincubator/create-react-app/issues/637 @@ -35,8 +36,26 @@ var nodePaths = (process.env.NODE_PATH || '') .filter(Boolean) .map(resolveApp); +var envPublicUrl = process.env.PUBLIC_URL; + +function getPublicUrl(appPackageJson) { + return envPublicUrl ? 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