const activeEnv = process.env.GATSBY_ACTIVE_ENV || 'development';
const { getDomain } = require('./src/helpers/common');

// eslint-disable-next-line import/no-extraneous-dependencies
require('dotenv').config({
  path: `.env.${activeEnv}`,
});

module.exports = (themeOptions = {}) => ({
  flags: {
    DEV_SSR: false,
  },
  plugins: [
    {
      resolve: `gatsby-core-theme`,
      options: {
        siteName: process.env.GATSBY_SITE_NAME,
        preconnectLinks: [getDomain(process.env.IMAGE_CDN_URL)],
        ...themeOptions,
      },
    },
    `gatsby-plugin-image`,
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
  ],
});
