This is how I managed to get it working.
I added the site on Netlify by linking it via a Github repository. Then inside on Netlify, I did the flowing:
- Click on the
Sites menu link and select the site you would like to deploy
- To access the
Settings, click on either:
- The
Site Settings button - is located in the first block/widget below the menu
Deploys in the menu next to Site Overview then click the Deploy setting button - located in the first block/widget below the menu
- Below the first block/widget click the link
Build & deploy -
located in the left side navigation aside
- In the
Build settings widget block, click the Edit settings button.
- Change
Base directory to ./
- Change
Build command to npm run build
- Change
Publish directory to ./build
- Scroll down to
Environment variables and add the key PRODUCTION, set the value of PRODUCTION to true
Retry your build to see if the configuration worked.
Side note: It's a fresh create react app react install, no 3rd party librarys yet.
Happy Coding =)
Pro Tip - create a netlify.toml file in the root of your project and add the following:
# Production context:
# All deploys from the main repository branch
# will inherit these settings.
[context.production]
command = "npm run build"
[context.production.environment]
PRODUCTION = "true"
Ive noticed that using a boolean value as a string works but if you use it like normal the build breaks