text: var proxy = require('http-proxy-middleware');
  require('dotenv').config({
    path: `.env.${process.env.NODE_ENV}`,
  });
  
  module.exports = {
    siteMetadata: {
      title: 'Gatsby + BigCommerce + Netlify CMS Starter',
      description:
        'This repo contains an example ecommerce website that is built with Gatsby, BigCommerce and Netlify CMS. It follows the JAMstack architecture by using Git as a single source of truth for content, BigCommerce for catalog / cart / checkout, and Netlify for continuous deployment.'
    },
    plugins: [
      {
        resolve: 'gatsby-source-bigcommerce',
        options: {
          // REQUIRED
          clientId: 'l26wiro9lfv2i3fdf2stxnd11nresoi',
          secret: 'c1f1b37b74ca0a3a4cfaec0a2f6fd7481cd352f168d887b96898dc3e66569a49',
          accessToken: '8j0atusrnz8fox403vzsnk89mewk0c0',
          storeHash: 'rrkthmg6r6',
          endpoints: {
            BigCommerceProducts: '/catalog/products?include=images,variants,custom_fields,options,modifiers,videos',
            BigCommerceCategories: '/catalog/categories',
            BigCommerceBrands: "/catalog/brands"
          }
        }
      },
      // {
      //   resolve: `gatsby-source-datocms`,
      //   options: {
      //     apiToken: `ec5d17ba2b571cf85e44be6213f28c`,
      //     preview: false,
      //     disableLiveReload: false,
      //   },
      // },
      {
        resolve: 'gatsby-source-prismic',
        options: {
          // The name of your prismic.io repository. This is required.
          // Example: 'gatsby-source-prismic-test-site' if your prismic.io address
          // is 'gatsby-source-prismic-test-site.prismic.io'.
          repositoryName: 'wellairsolutions',
    
          // An API access token to your prismic.io repository. This is optional.
          // You can generate an access token in the "API & Security" section of
          // your repository settings. Setting a "Callback URL" is not necessary.
          // The token will be listed under "Permanent access tokens".
          accessToken: `${process.env.API_KEY}`,
    
          // If you provide a release ID, the plugin will fetch data from Prismic
          // for a specific release. A Prismic release is a way to gather a
          // collection of changes for a future version of your website. Note that
          // if you add changes to a release, you'll need to rebuild your website
          // to see them.
          // See: https://user-guides.prismic.io/en/collections/22653-releases-scheduling#the-basics-of-a-release
          releaseID: 'example-eiyaingiefahyi7z',
    
          // Set a link resolver function used to process links in your content.
          // Fields with rich text formatting or links to internal content use this
          // function to generate the correct link URL.
          // The document node, field key (i.e. API ID), and field value are
          // provided to the function, as seen below. This allows you to use
          // different link resolver logic for each field if necessary.
          // See: https://prismic.io/docs/javascript/query-the-api/link-resolving
          linkResolver: ({ node, key, value }) => (doc) => {
            // Your link resolver
            if (doc.type === 'product') {
              return `/product/${doc.uid}`
            }
            if (doc.type === 'page') {
              return `/${doc.uid}`
            }
          },
    
          // Set a list of links to fetch and be made available in your link
          // resolver function.
          // See: https://prismic.io/docs/javascript/query-the-api/fetch-linked-document-fields
          fetchLinks: [
            // Your list of links
          ],
    
          // Set an HTML serializer function used to process formatted content.
          // Fields with rich text formatting use this function to generate the
          // correct HTML.
          // The document node, field key (i.e. API ID), and field value are
          // provided to the function, as seen below. This allows you to use
          // different HTML serializer logic for each field if necessary.
          // See: https://prismic.io/docs/nodejs/beyond-the-api/html-serializer
          htmlSerializer: ({ node, key, value }) => (
            type,
            element,
            content,
            children,
          ) => {
            // Your HTML serializer
          },
    
          // Provide an object of Prismic custom type JSON schemas to load into
          // Gatsby. This is required.
          schemas: {
            product: require('./src/schemas/product.json'),
          },
    
          // Set a default language when fetching documents. The default value is
          // '*' which will fetch all languages.
          // See: https://prismic.io/docs/javascript/query-the-api/query-by-language
          lang: '*',
    
          // Add the Prismic Toolbar script to the site. Defaults to false.
          // Set to "legacy" if your repository requires the older toolbar script.
          // See: https://prismic.io/docs/rest-api/beyond-the-api/the-preview-feature
          prismicToolbar: true,
    
          // Set a function to determine if images are downloaded locally and made
          // available for gatsby-transformer-sharp for use with gatsby-image.
          // The document node, field key (i.e. API ID), and field value are
          // provided to the function, as seen below. This allows you to use
          // different logic for each field if necessary.
          // This defaults to always return false.
          shouldDownloadImage: ({ node, key, value }) => {
            // Return true to download the image or false to skip.
          },
    
          // Provide a default set of Imgix image transformations applied to
          // Imgix-backed gatsby-image fields. These options will override the
          // defaults set by Prismic.
          // See: https://docs.imgix.com/apis/url
          imageImgixParams: {
            auto: 'compress,format',
            fit: 'max',
            q: 50,
          },
    
          // Provide a default set of Imgix image transformations applied to
          // the placeholder images of Imgix-backed gatsby-image fields. These
          // parameters will be applied over those provided in the above
          // `imageImgixParams` option.
          // See: https://docs.imgix.com/apis/url
          imagePlaceholderImgixParams: {
            w: 100,
            blur: 15,
            q: 50,
          },
    
          // Set the prefix for the filename where type paths for your schemas are
          // stored. The filename will include the MD5 hash of your schemas after
          // the prefix.
          // This defaults to 'prismic-typepaths---${repositoryName}'.
          typePathsFilenamePrefix:
            'prismic-typepaths---gatsby-source-prismic-test-site',
        },
      },
      'gatsby-plugin-react-helmet',
      'gatsby-plugin-sass',
      {
        // keep as first gatsby-source-filesystem plugin for gatsby image support
        resolve: 'gatsby-source-filesystem',
        options: {
          path: `${__dirname}/static/img`,
          name: 'uploads'
        }
      },
      {
        resolve: 'gatsby-source-filesystem',
        options: {
          path: `${__dirname}/src/pages`,
          name: 'pages'
        }
      },
      {
        resolve: 'gatsby-source-filesystem',
        options: {
          path: `${__dirname}/src/img`,
          name: 'images'
        }
      },
      'gatsby-plugin-sharp',
      'gatsby-transformer-sharp',
      {
        resolve: 'gatsby-transformer-remark',
        options: {
          plugins: [
            {
              resolve: 'gatsby-remark-relative-images',
              options: {
                name: 'uploads'
              }
            },
            {
              resolve: 'gatsby-remark-images',
              options: {
                // It's important to specify the maxWidth (in pixels) of
                // the content container as this plugin uses this as the
                // base for generating different widths of each image.
                maxWidth: 2048
              }
            },
            {
              resolve: 'gatsby-remark-copy-linked-files',
              options: {
                destinationDir: 'static'
              }
            }
          ]
        }
      },
      {
        resolve: 'gatsby-plugin-netlify-cms',
        options: {
          modulePath: `${__dirname}/src/cms/cms.js`
        }
      },
      {
        resolve: 'gatsby-plugin-purgecss', // purges all unused/unreferenced css rules
        options: {
          develop: true, // Activates purging in npm run develop
          purgeOnly: ['/all.sass'] // applies purging only on the bulma css file
        }
      }, // must be after other CSS plugins
      'gatsby-plugin-netlify' // make sure to keep it last in the array
    ],
    // for avoiding CORS while developing Netlify Functions locally
    // read more: https://www.gatsbyjs.org/docs/api-proxy/#advanced-proxying
    developMiddleware: app => {
      app.use(
        '/.netlify/functions/',
        proxy({
          target: 'http://localhost:9000',
          pathRewrite: {
            '/.netlify/functions/': ''
          }
        })
      );
    }
  };
  