gatsby: gatsby build very slow

Description

Trying out gatsby for the first time. Not sure if “blazing fast” applies to the production builds, or just while developing, or maybe I’m using the wrong command. Any help is appreciated.

Running gatsby build. Site created from gatsby-starter-docs which is based on gatsby-advanced-starter. If this is unusual performance, a pointer to a known fast base would be appreciated.

Gatsby version: 1.8.11

info bootstrap finished - 2.292 s

success Generating CSS — 53.505 s
success Compiling production bundle.js — 96.203 s
success Generating static HTML for pages — 44.830 s
Total precache size is about 405 kB for 5 resources.
success Done building in 197.28 seconds

Gatsby version 1.9.149 (upgraded all deps in the project to the ‘latest’ npm tag).

info bootstrap finished - 2.656 s

success Building CSS — 37.436 s
success Building production JavaScript bundles — 79.457 s
success Building static HTML for pages — 39.995 s
Total precache size is about 737 kB for 8 resources.
info Done building in 159.631 sec

It’s fast in development mode, but the development startup time is also quite slow. The server doesn’t even listen on the port for around 8 seconds.

Development mode output:

info bootstrap finished - 2.827 s

 DONE  Compiled successfully in 36494ms                                       21:11:13


You can now view high-redux-docs in the browser.

  http://localhost:9911/

View GraphiQL, an in-browser IDE, to explore your site's data and schema

  http://localhost:9911/___graphql

Note that the development build is not optimized.
To create a production build, use gatsby build

 WAIT  Compiling...                                                           21:11:13

 DONE  Compiled successfully in 1615ms

Environment

Gatsby version: 1.8.11, also tried upgrading to ^1.9.149 Node.js version: 8.9.0 Operating System: OSX, Darwin {my host} 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

File contents (if changed):

Repo here: https://github.com/brigand/high-redux-docs

Running yarn build:pp.

Actual result

It takes a very long time, even if I don’t modify any files between runs.


Thanks for the otherwise amazing tool!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 20 (11 by maintainers)

Most upvoted comments

It is actually quite a pain when you are debugging SSR issues.

😕

If you want fast builds, turns out you need the newly announced Gatsby builds, part of the commercial Gatsby Cloud offering.

I’m on Gatsby 2.18.8, and building a very simple site takes 3 minutes on a VPS with 2GB RAM.

The build process stays stuck at this step for 2 minutes:

image

The last lines of the output are:

success Build manifest and related icons - 9.118s
success onPostBootstrap - 9.139s
⠀
info bootstrap finished - 69.210 s
⠀
success Building production JavaScript and CSS bundles - 102.993s
success Rewriting compilation hashes - 0.068s
success run queries - 104.050s - 3/3 0.03/s
success Building static HTML for pages - 12.770s - 6/6 0.47/s
info Generated public/sw.js, which will precache 12 files, totaling 404375 bytes.
The following pages will be precached:
/offline-plugin-app-shell-fallback/index.html
/about/index.html
/blog/index.html
info Done building in 186.735163138 sec

I’m using https://github.com/AustinGreen/gatsby-starter-netlify-cms, all content local, 3 pages, and build time is 60 seconds. Updated all packages to the latest.

Definitely very slow.

Mostly the JS bundle build.

I have been doubly spoiled by the speed of Parcel Bundler.

success delete html and css files from previous builds — 0.034 s
success open and validate gatsby-config.js — 0.006 s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
success copy gatsby files — 0.018 s
success onPreBootstrap — 0.834 s
success source and transform nodes — 0.134 s
success building schema — 0.225 s
success createLayouts — 0.009 s
success createPages — 0.051 s
success createPagesStatefully — 0.019 s
success onPreExtractQueries — 0.001 s
success update schema — 0.136 s
success extract queries from components — 0.111 s
success run graphql queries — 0.115 s
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s

info bootstrap finished - 4.033 s

success Building CSS — 8.980 s
success Building production JavaScript bundles — 43.632 s
success Building static HTML for pages — 3.937 s
info Done building in 60.587 sec

@brigand do you have instructions on how to implement both of those tips? Sounds like very useful hacks I could use.

By my current setup, I mean my gatsby site with the slow build. It’s not an issue, I just wasn’t sure if I was doing things correctly. I’m sorry I didn’t express that clearly. Thanks for the great project!

I created the project with the gatsby cli, wrote three markdown pages with no images, and then tried a build. So my best guess is that gatsby-advanced-starter is pulling in a lot of stuff. It seems to have many features.

Thanks for the clarification and your build times. Quite a difference objectively, but 80 seconds vs 159 seconds both fall in the “slow-ish” category, so optimizing down to that point isn’t super valuable.

I’ll stick with my current setup for this project, and try out 2.0 when it’s released.