text: const { ImgixSourceType } = require('@imgix/gatsby');
  
  require("dotenv").config({
    path: `.env.${process.env.NODE_ENV}`,
  });
  
  const contentfulConfig = {
    spaceId: process.env.CONTENTFUL_SPACE_ID,
    accessToken:
      process.env.CONTENTFUL_ACCESS_TOKEN ||
      process.env.CONTENTFUL_DELIVERY_TOKEN,
  };
  
  // If you want to use the preview API please define
  // CONTENTFUL_HOST and CONTENTFUL_PREVIEW_ACCESS_TOKEN in your
  // environment config.
  //
  // CONTENTFUL_HOST should map to `preview.contentful.com`
  // CONTENTFUL_PREVIEW_ACCESS_TOKEN should map to your
  // Content Preview API token
  //
  // For more information around the Preview API check out the documentation at
  // https://www.contentful.com/developers/docs/references/content-preview-api/#/reference/spaces/space/get-a-space/console/js
  //
  // To change back to the normal CDA, remove the CONTENTFUL_HOST variable from your environment.
  if (process.env.CONTENTFUL_HOST) {
    contentfulConfig.host = process.env.CONTENTFUL_HOST;
    contentfulConfig.accessToken = process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN;
  }
  
  const { spaceId, accessToken } = contentfulConfig;
  
  if (!spaceId || !accessToken) {
    throw new Error(
      "Contentful spaceId and the access token need to be provided."
    );
  }
  
  module.exports = {
    siteMetadata: {
      title: `Gatsby Default Starter`,
      description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
      author: `Tom Dale`,
      siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`,
    },
    plugins: [
      `gatsby-plugin-react-helmet`,
      `gatsby-plugin-image`,
      {
        resolve: `gatsby-source-filesystem`,
        options: {
          name: `images`,
          path: `${__dirname}/src/images`,
        },
      },
      {
        resolve: "gatsby-source-contentful",
        options: contentfulConfig,
      },
      `gatsby-transformer-sharp`,
      `gatsby-plugin-sharp`,
      {
        resolve: `gatsby-plugin-manifest`,
        options: {
          name: `gatsby-starter-default`,
          short_name: `starter`,
          start_url: `/`,
          background_color: `#663399`,
          // This will impact how browsers show your PWA/website
          // https://css-tricks.com/meta-theme-color-and-trickery/
          // theme_color: `#663399`,
          display: `minimal-ui`,
          icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
        },
      },
      // this (optional) plugin enables Progressive Web App + Offline functionality
      // To learn more, visit: https://gatsby.dev/offline
      // `gatsby-plugin-offline`,
      {
        resolve: `@imgix/gatsby`,
        options: {
          // This is the domain of your imgix source, which can be created at
          // https://dashboard.imgix.com/.
          // Only "Web Proxy" imgix sources can be used for this configuration.
          domain: 'tom-proxy.imgix.net',
  
          // This is the source's secure token. Can be found under the "Security"
          // heading in your source's configuration page, and revealed by tapping
          // "Show Token".
          secureURLToken: process.env.IMGIX_SECURE_TOKEN, // replace this token
  
          // This configures the plugin to work in proxy mode.
          sourceType: ImgixSourceType.WebProxy,
  
          // These are some default imgix parameters to set for each image. It is
          // recommended to have at least this minimal configuration.
          defaultImgixParams: { auto: 'format,compress' },
          // This configures which nodes to modify.
          fields: [
            {
              nodeType: "ContentfulAsset",
              fieldName: "imgixImage",
              getURL: node => `https:${node.file.url}`
            }
          ],
        },
      },
    ],
  }
  