Build issues with Gatsby and Sanity blog starter project
12 replies
Last updated: Apr 28, 2020
D
Hey all! Has anyone had any build issues when trying to run a gatsby build on the Sanity blog starter project? I am getting this…
Apr 27, 2020, 2:38 PM
P
Thanks for the heads up, User! There should be a line at the top of that file:
It should also check for empty
const {format} = require('date-fns')
publishedAtfields in the GraphQL query. I’ll check if I can reproduce the issue 👍
Apr 27, 2020, 2:51 PM
D
Thanks User. Yes I see it. I do have a draft that’s not been published and without a date. That’s been the only change on the project so far..
Apr 27, 2020, 2:57 PM
D
The graphql does filter them…
filter: { slug: { current: { ne: null } }, publishedAt: { ne: null } }
Apr 27, 2020, 2:58 PM
F
I had the same kind of problem with date in Gatsby before: that was a matter of date format. Here I see
YYYY/MMand Gatsby only accept
YYYY-MMor may be complete
YYYY-MM-DD. I am not sure though.
Apr 27, 2020, 3:45 PM
D
Here is a data dump of the data it’s looping through.
Apr 27, 2020, 4:02 PM
P
Hi again User, I just tried to replicate the issue by starting from scratch at https://www.sanity.io/create with the Gatsby blog template. However, it successfully runs
You created your project via
sanity.io/create , correct? And you get the error when running your build locally? Have you tried re-creating the blog from scratch?
gatsby developand
gatsby build && gatsby servein /web, as well as
npm run buildin root. So it looks like we need to dive in deeper to figure out what the issue is.
You created your project via
sanity.io/create , correct? And you get the error when running your build locally? Have you tried re-creating the blog from scratch?
Apr 27, 2020, 6:32 PM
D
That’s correct yeah. Haven’t tried re-creating it from scratch… i’ll give it a try tomorrow and see how I get on and let you know. Thanks for looking into it User 👍
Apr 27, 2020, 7:57 PM
D
Ok, so I can confirm that the problem was upgrading the projects dependencies. (forgot that I did that, sorry). So it appears to be a problem with 1 or more of the following deps. (Not including latest gatsby as it still builds on the below version)
Apr 28, 2020, 11:36 AM
D
Might be worth trying to replicate with that and see if you have the same build problem. I’m unable to go through each dependancie at the moment to see which ones are causing the problems, but if you’d like me to when i’m able, please let me know 🙂
Apr 28, 2020, 11:37 AM
D
There does seem to be a particular issue around using the latest date-fns, for which
user S
gave a possible work around. with the belowimport { format, parseISO } from 'date-fns' ... const dateSegment = format(parseISO(publishedAt), 'yyyy/MM')
Apr 28, 2020, 11:39 AM
P
Hi again User, thanks for confirming and for sharing all these extra details 👍 Looks like we have to do some maintenance to bring the template up to the latest version of
date-fnswithout breaking it 🙂 Hope you can move forward for now, but I’ll ping you when we release an update.
Apr 28, 2020, 11:55 AM
D
Thanks User, that would be great. Thanks for your help on this 👍
Apr 28, 2020, 2:40 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.