Error when adding blog posts to Gatsby portfolio site
I appreciate you reaching out, but I need to be upfront with you: this is actually a Gatsby/webpack/CSS modules issue, not a Sanity-specific problem. While you're building a Sanity-powered Gatsby site, the error you're encountering is purely on the frontend build side and doesn't involve Sanity's APIs, Studio, or content delivery.
The error is clear—you have an invalid CSS class name !block in your figure.module.css file that webpack's CSS loader can't parse because ! isn't valid in JavaScript variable names (CSS modules export classes as JS constants).
For help with this specific error, you'll get better support from:
- The Gatsby Discord or Gatsby GitHub Discussions
- Stack Overflow with tags for
gatsby,webpack, andcss-modules - General frontend/React development communities
That said, here's the quick fix: Open src/components/figure.module.css around line 11 and either remove the ! prefix from the class name or rename it to something valid like .forceBlock. If you're using Tailwind's !important modifier, apply it directly in JSX (className="!block") rather than in CSS modules, or use display: block !important; in your CSS instead.
Regarding Sanity + Gatsby specifically: If you're starting a new project or considering a refresh, you might want to know that Gatsby's source-sanity plugin is still maintained, but many developers have moved to Next.js for Sanity projects due to better real-time preview support, incremental static regeneration, and features like the Live Content API which works seamlessly with modern React frameworks. If you're happy with Gatsby though, it's still a perfectly valid choice!
Good luck fixing the CSS issue—it should be a quick fix once you locate that problematic class name!
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.