const {
  ANALYZER,
  GRAPH_CMS_ENDPOINT,
  GRAPH_CMS_TOKEN,
  SERVICE_NAME,
  STAGE
} = process.env;

const modifyVars = {
  'primary-color': 'red',
  'padding-sm': '12px',
  'padding-md': '24px',
};

const theme = {

}

const configs = {
  siteMetadata: {
    title: `Gatsby Typescript Starter`
  },
  plugins: [
    {
      resolve: 'gatsby-plugin-antd',
      options: {
        style: true
      }
    },
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-typescript`,
    {
      resolve: `gatsby-plugin-less`,
      options: {
        javascriptEnabled: true,
        modifyVars
      }
    },
    {
      resolve: `gatsby-source-graphql`,
      options: {
          typeName: "GCMS",
          fieldName: "gcms",
          headers: {
            Authorization: GRAPH_CMS_TOKEN,
          },
          url: GRAPH_CMS_ENDPOINT,
      },
    },
    {
      resolve: `gatsby-plugin-s3`,
      options: {
        bucketName: `${SERVICE_NAME}-website-${STAGE}`
      }
    },
  ],
}


if (ANALYZER === "true") {
  configs.plugins.push({
    resolve: 'gatsby-plugin-webpack-bundle-analyzer',
    options: { production: false },
  });
}

module.exports = configs;