Reading how to exclude a directory on build I ran across this issue in Gatsby and it indicated to ignore a directory in gatsby-source-filesystem
you can ignore based on env
with:
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/content`,
ignore: process.env.NODE_ENV === `production` && [`**/draft-*`]
}
}
ref but when I try to use a similar approach with:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `designs`,
path: `${__dirname}/src/designs/`,
ignore: process.env.NODE_ENV === `production` && [`*`],
},
},
it throws a terminal error of:
Invalid plugin options for "gatsby-source-filesystem":
- "ignore" must be an array
I am bringing in dotenv
at the top of gatsby-config.js with:
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
and if the env
condition is removed it works:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `designs`,
path: `${__dirname}/src/designs/`,
ignore: [`*`],
},
},
I was reading "How to unpublish a gatsby page without deleting it?" that led me to this question. I do not have an issue with it working on npm run build
just with npm run develop
. In Gatsby develop is there a way to use an ignore with an env condition?