I'm developing a React web app with Gatsby. After adding over a 1000 static markdown files, the build process requires a lot of memory. I'm running the builds under AWS Lambda, and I've started to get SIGKILLs once the memory limit of 1536MB is exhausted.
How could Gatsby builds be scaled to thousands of files without requiring more and more memory? According to the developer, it should be possible.
Gatsby pulls all site content, css, js into memory while doing a build. Potentially there's ways to reduce the amount of memory Gatsby uses but currently the best way to reduce your memory usage would be to split the site into identical but separate sites. I.e. keep the templates/css the same but 1000s of Markdown files into multiple sites and build each separately in sequence.
node --max-old-space-size=8192 node_modules/.bin/gatsby build
That's how I ran the benchmark when I was trying to make webpack faster. Was building upwards of 5000+ markdown posts.
Try disabling the BABEL_CACHE environment variable. I have run into problems on AWS lambda, too, and moved to Docker based builds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With