Q:

Choose createPages gatsby component based on server side rendering or browser rendering

I am using createPages to automatically generate components based on some JSON input, like this:
exports.createPages = ({ graphql, boundActionCreators }) => {
  const { createPage } = boundActionCreators
  return new Promise((resolve, reject) => {
    graphql(`
{
  allPageJson{
    edges {
      node {
        id
        url
      }
    }
  }
}
    `).then(result => {
      result.data.allPageJson.edges.map(({ node }) => {
        createPage({
          path: node.url,
          component: path.resolve(`./src/templates/page.js`),
          context: {
            id: node.id,
          },
        })
      })
      resolve()
    })
  })
}

What I am looking for is a parameter or helper that tells me if I'm currently running in build mode or in develop mode, so something like this:
exports.createPages = ({ isBuildMode }) => {
  if (isBuildMode) {
     console.log('looks like you ran gatsby build')
     return
  }
  console.log('looks like you ran gatsby develop')
}

A:

process.env.NODE_ENV is your best bet atm. Happy to discuss other options in an issue!

