next.config.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const { locales, defaultLocale } = require("./data/locales.js")
  2. /** @type {import('next').NextConfig} */
  3. const nextConfig = {
  4. reactStrictMode: true,
  5. i18n: {
  6. locales: locales.map((l) => l.code),
  7. defaultLocale,
  8. },
  9. images: {
  10. domains: [
  11. "proxy.joinmastodon.org",
  12. "c8.patreon.com",
  13. "c10.patreonusercontent.com",
  14. ],
  15. },
  16. async headers() {
  17. // These static files are references with hardcoded URLs and need proper Cache-Control headers
  18. return [
  19. "/fonts/:all*(ttf|otf|woff|woff2)",
  20. "/favicon-:all*(png)",
  21. "/app-icon.png",
  22. "/preview.png",
  23. ].map((source) => ({
  24. source,
  25. headers: [
  26. {
  27. key: "Cache-control",
  28. value: "max-age=3600, stale-while-revalidate",
  29. },
  30. ],
  31. }))
  32. },
  33. async redirects() {
  34. return [
  35. {
  36. source: "/communities",
  37. destination: "/servers",
  38. permanent: true,
  39. },
  40. {
  41. source: "/imprint",
  42. destination: "/about#impressum",
  43. permanent: true,
  44. },
  45. {
  46. source: "/impressum",
  47. destination: "/about#impressum",
  48. permanent: true,
  49. },
  50. ]
  51. },
  52. webpack(config, { isServer, isdev }) {
  53. // Grab the existing rule that handles SVG imports
  54. const fileLoaderRule = config.module.rules.find(
  55. (rule) => rule.test && rule.test.test?.(".svg")
  56. )
  57. config.module.rules.push({
  58. oneOf: [
  59. // warning: do not specify `issuer` key here, it is broken with dynamic require
  60. // see https://github.com/webpack/webpack/issues/9309
  61. // https://github.com/vercel/next.js/discussions/15437
  62. {
  63. test: /\.svg$/i,
  64. resourceQuery: /inline/, // Only for *.svg?inline
  65. use: [{ loader: "@svgr/webpack", options: { svgo: false } }],
  66. },
  67. // we need to add this, as the previous rule disabled the default SVG loader
  68. {
  69. ...fileLoaderRule,
  70. test: /\.svg$/i,
  71. resourceQuery: { not: [/inline/] },
  72. },
  73. ],
  74. })
  75. // Modify the file loader rule to ignore *.svg, since we have it handled now.
  76. fileLoaderRule.exclude = /\.svg$/i
  77. return config
  78. },
  79. output: "standalone",
  80. }
  81. module.exports = nextConfig