The most frustrating part is that I had this working earlier then somehow broke it, but I'm using gatsby-plugin-sharp and gatsby-plugin-image to add a photo to my homepage and seeing this error:
Gatsby-plugin-sharp wasn't setup correctly in gatsby-config.js. Make sure you add it to the plugins array.
I have no idea why... I've tried deleting node_modules, package_lock.json, reinstalling... beyond that I can also tell that the plugin is certainly in my array, and if I add options to the plugin-sharp that are unresolved, it asks me about them when the plugin loads.
I'm not sure if I need to order them in a different way and am kicking myself for not backing up.
gatsby-config.js:
module.exports = {
siteMetadata: {
siteUrl: 'myinfo-redacted',
name: "myinfo-redacted",
defaultTitle: "Bmyinfo-redacted",
titleTemplate: "%s • myinfo-redacted",
description: "myinfo-redacted",
author: "myinfo-redacted",
hero: {
heading: "myinfo-redacted",
subHeading: "myinfo-redacted",
},
social: [
{
name: "twitter",
url: "myinfo-redacted",
},
{
name: "linkedin",
url: "myinfo-redacted",
},
{
name: "devto",
url: "myinfo-redacted",
},
{
name: "youtube",
url: "myinfo-redacted",
},
],
},
plugins: [
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/gatsby-theme-purist/images`
},
},
{
resolve: 'gatsby-theme-purist',
options: {
contentBase: 'content',
basePath: '/',
featuredArticleLimit: 2,
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Bryan Barrows`,
short_name: `Bryan Barrows`,
start_url: `/`,
icon: 'static/favicon.png'
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `markdown-pages`,
path: `${__dirname}/content/articles`,
ignore: [`**/drafts`]
},
},
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMdx } }) => {
return allMdx.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.frontmatter.description,
date: edge.node.frontmatter.date,
author: site.siteMetadata.name,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
custom_elements: [{ "content:encoded": edge.node.html }]
});
});
},
query: `
{
allMdx(
sort: { order: DESC, fields: [frontmatter___date] }, filter: {frontmatter: { draft: {eq: false} }}
) {
edges {
node {
excerpt
html
fields { slug }
frontmatter {
title
date
description
author
}
}
}
}
}
`,
output: "/rss.xml",
title: "Bryan Barrows RSS Feed",
// optional configuration to insert feed reference in pages:
// if `string` is used, it will be used to create RegExp and then test if pathname of
// current page satisfied this regular expression;
// if not provided or `undefined`, all pages will have feed reference inserted
match: "^/articles/"
}
]
}
},
{
resolve: "gatsby-plugin-social9-socialshare",
options: {
content: "ca24ce819d944595a0a4c3f53125d1a8",
async: true,
defer: true
}
},
{
resolve: 'gatsby-plugin-offline',
options: {}
},
],
}
package.json:
{
"name": "gatsby-starter-purist",
"version": "1.0.0",
"main": "index.js",
"repository": "",
"author": "Sebastian Ojeda <hello@sebastianojeda.com> (@sebsojeda)",
"license": "0BSD",
"private": true,
"scripts": {
"start": "yarn dev",
"dev": "GATSBY_GRAPHQL_IDE=playground gatsby develop",
"build": "gatsby build",
"clean": "gatsby clean"
},
"dependencies": {
"gatsby": "^4.0.0-next",
"gatsby-image": "^3.11.0",
"gatsby-plugin-feed": "^4.4.0",
"gatsby-plugin-image": "^2.4.0",
"gatsby-plugin-manifest": "^4.3.0",
"gatsby-plugin-mdx": "^3.4.0",
"gatsby-plugin-offline": "^5.3.0",
"gatsby-plugin-sharp": "^3.8.0",
"gatsby-plugin-social9-socialshare": "^1.0.5",
"gatsby-remark-images": "^6.4.0",
"gatsby-source-filesystem": "^4.4.0",
"gatsby-theme-purist": "^1.3.0",
"gatsby-transformer-remark": "^5.3.0",
"gatsby-transformer-sharp": "^4.4.0",
"markdown-to-jsx": "^7.1.5",
"react": "^16.14.0",
"react-dom": "^16.14.0"
}
}
The fact that it was working as intended earlier today leads me to believe that it should be possible and that something got funky with the gatsby-config.js - particularly becuase of the error about misconfiguration or it missing from plugin array.