Requirements
- Code editor
- Netlify
- Gatsby.js
Introduction
As you are building a Gatsby project, at a development point, you can encounter no errors whatsoever, but at a build stage, you can be surprised with one or many bugs that slip past through you.
Problem
Let's say you successfully configure the Netlify CLI and deploy your project. Then you get something like this in the Deploys section of the Netlify site page:
Production: master @id_number
Then you look at the Deploy log:
Why does this happen?
The Gatsby project structure is different than let's say React, that the build process adds a build folder. Gatsby builds the app for deployment in the public folder. So normally Netlify will try to find a build folder as a default configuration.
Solution
To resolve this problem we have to find a way to make Netlify look for build files at the public folder instead.
Netlify has a way to edit the build settings, deploy settings, and environment variables (more information about that at the Additional Resources section) so we can fix those kinds of bugs easily.
Create a file at the root file of your project.
Populate the file as such:
The publish setting is the one that can change the default build file for the Netlify build process. This is relative to the base directory.
