gatsby-config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import dotenv from 'dotenv';
  2. import { getThemeVariables } from 'antd/dist/theme';
  3. import supportedLanguages from './src/utils/i18n/supportedLanguages';
  4. import antdThemeOverrides from './src/AntdTheme';
  5. dotenv.config({
  6. path: `.env.${process.env.NODE_ENV}`,
  7. });
  8. const languages = supportedLanguages.map(language => language.languageTag);
  9. const plugins = [
  10. 'gatsby-plugin-react-helmet',
  11. 'gatsby-plugin-typescript',
  12. 'gatsby-plugin-remove-serviceworker',
  13. 'gatsby-plugin-svgr',
  14. {
  15. resolve: 'gatsby-plugin-intl',
  16. options: {
  17. path: `${__dirname}/src/locales`,
  18. languages,
  19. defaultLanguage: 'en',
  20. redirect: true,
  21. },
  22. },
  23. {
  24. resolve: 'gatsby-plugin-antd',
  25. options: {
  26. style: true,
  27. },
  28. },
  29. {
  30. resolve: `gatsby-plugin-less`,
  31. options: {
  32. lessOptions: {
  33. javascriptEnabled: true,
  34. modifyVars: {
  35. ...getThemeVariables({
  36. dark: true, // Enable dark mode
  37. compact: true, // Enable compact mode,
  38. }),
  39. ...antdThemeOverrides,
  40. },
  41. },
  42. },
  43. },
  44. {
  45. resolve: 'gatsby-plugin-robots-txt',
  46. options: {
  47. host: process.env.GATSBY_SITE_URL,
  48. sitemap: `${process.env.GATSBY_SITE_URL}/sitemap.xml`,
  49. env: {
  50. development: {
  51. policy: [{ userAgent: '*', disallow: ['/'] }]
  52. },
  53. production: {
  54. policy: [{ userAgent: '*', allow: '/' }]
  55. }
  56. }
  57. }
  58. },
  59. {
  60. resolve: "gatsby-plugin-sitemap",
  61. options: {
  62. serialize: ({ site, allSitePage }) => {
  63. // filter out pages that do not include a locale, along with locale specific 404 pages.
  64. const edges = allSitePage.edges.filter(page => languages.some(lang => page.node.path.includes(lang)) && !page.node.path.includes('404'))
  65. // return sitemap entries
  66. return edges.map(page => {
  67. return {
  68. url: `${site.siteMetadata.siteUrl}${page.node.path}`,
  69. // changefreq: `daily`,
  70. // priority: 0.7,
  71. // lastmod: modifiedGmt,
  72. }
  73. })
  74. },
  75. exclude: [
  76. process.env.ENABLE_NETWORK_PAGE !== 'true' ? '/*/network/' : '/',
  77. process.env.ENABLE_EXPLORER_PAGE !== 'true' ? '/*/explorer/' : '/',
  78. ]
  79. },
  80. },
  81. {
  82. resolve: `gatsby-plugin-google-gtag`,
  83. options: {
  84. trackingIds: [String(process.env.GATSBY_GA_TAG)],
  85. },
  86. },
  87. ];
  88. // Bundle analyzer, dev only
  89. if (process.env.ENABLE_BUNDLE_ANALYZER === '1') {
  90. plugins.push('gatsby-plugin-webpack-bundle-analyser-v2');
  91. }
  92. const siteMetadata = {
  93. siteUrl: process.env.GATSBY_SITE_URL,
  94. }
  95. export { plugins, siteMetadata };