Getting Incremental Builds setup with Gatsby and DatoCMS
May 27, 2020
Peter Hironaka - Front End Developer@peterhironaka
Gatsby released an exciting new feature a month or so ago - incremental builds. So...what are incremental builds?
Let's compare the process with a traditional server rendered website, like an old Wordpress blog. If you're writing a blog post/editing a post/code update, a post request is made to your server and from there, a page gets rendered/updated.
With static site generators (SSG) or statically rendered web apps like a Gatsby site, any content or code update you make to your site requires the entire site to rebuild. While you get significant performance and security benefits from this process, it can lead to longer build times. Think about if you have a site with 1000+ pages...it could take several minutes before that update gets pushed to production.
Incremental builds solves this problem, and it is a GAME CHANGER. It narrows the divide between dynamic and "static" sites considerably. Now any content changes you make can be seen almost instantaneously. Gatsby even released a new site yesterday to benchmark how long build times will take according to different content management systems they support.
Even better - Jason Lengstorf release a really handy blog post on how to enable incremental builds on Netlify for free!
Important to note that if you use Yarn for dependency management, it will not work (at least on Netlify). You will need to follow a few more steps listed below:
- Remove your yarn.lock, node modules folder and re-install your dependencies using
- Within your app.netlify site - update your build command to
npm run build
- Commit your changes to github to trigger a build
After that initial build has published, the subsequent builds should be super fast. Hope this was a helpful post! I'm exciting to impelment incremental builds across all my Gatsby sites.
*note: For incremental builds to work with DatoCMS, you will need to upgrade your dependency to 2.25.