Add public url to prod webpack config (#615)

* add public url to prod webpack config

* modify travis/webpack config to add public url

* add slash
This commit is contained in:
Mikhail Mikheev 2020-02-27 11:34:55 +01:00 committed by GitHub
parent 94539ec53e
commit 72268f7232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -36,7 +36,12 @@ after_success:
else
export NODE_ENV=development;
fi
- if [[ -n "$TRAVIS_TAG" ]]; then export REACT_APP_ENV='production'; fi
- |
if [[ -n "$TRAVIS_TAG" ]]; then
export PRODUCTION_DEPLOYMENT=true;
export REACT_APP_ENV='production';
fi
- yarn build
# Pull Request - Deploy it to a review environment
# Travis doesn't do deploy step with pull requests builds

View File

@ -54,7 +54,7 @@ function ensureSlash(path, needsSlash) {
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
const homepagePath = require(paths.appPackageJson).homepage
// var homepagePathname = homepagePath ? url.parse(homepagePath).pathname : '/';
const homepagePathname = "/"
const homepagePathname = process.env.PRODUCTION_DEPLOYMENT ? "/app/" : "/"
// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
const publicPath = ensureSlash(homepagePathname, true)