next.config.mjs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import withMDX from '@next/mdx';
  2. import env from './env.js';
  3. /** @type {import('next').NextConfig} */
  4. export default withMDX()({
  5. output: 'export',
  6. images: {
  7. unoptimized: true,
  8. },
  9. env: env,
  10. pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
  11. redirects: () => [
  12. {
  13. source: '/guides/upgrading-to-2-0',
  14. destination: '/docs/upgrading-to-2-0',
  15. permanent: true,
  16. },
  17. {
  18. source: '/guides/why-quill',
  19. destination: '/docs/why-quill',
  20. permanent: true,
  21. },
  22. {
  23. source: '/guides/how-to-customize-quill',
  24. destination: '/docs/customization',
  25. permanent: true,
  26. },
  27. {
  28. source: '/guides/building-a-custom-module',
  29. destination: '/docs/guides/building-a-custom-module',
  30. permanent: true,
  31. },
  32. {
  33. source: '/guides/cloning-medium-with-parchment',
  34. destination: '/docs/guides/cloning-medium-with-parchment',
  35. permanent: true,
  36. },
  37. {
  38. source: '/guides/designing-the-delta-format',
  39. destination: '/docs/guides/designing-the-delta-format',
  40. permanent: true,
  41. },
  42. {
  43. source: '/docs/registries',
  44. destination: '/docs/customization/registries',
  45. permanent: true,
  46. },
  47. {
  48. source: '/docs/themes',
  49. destination: '/docs/customization/themes',
  50. permanent: true,
  51. },
  52. ],
  53. webpack(config) {
  54. // Grab the existing rule that handles SVG imports
  55. const fileLoaderRule = config.module.rules.find((rule) =>
  56. rule.test?.test?.('.svg'),
  57. );
  58. config.module.rules.push(
  59. // Reapply the existing rule, but only for svg imports ending in ?url
  60. {
  61. ...fileLoaderRule,
  62. test: /\.svg$/i,
  63. resourceQuery: /url/, // *.svg?url
  64. },
  65. // Convert all other *.svg imports to React components
  66. {
  67. test: /\.svg$/i,
  68. issuer: fileLoaderRule.issuer,
  69. resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
  70. use: [
  71. {
  72. loader: '@svgr/webpack',
  73. options: {
  74. svgoConfig: {
  75. plugins: [{ name: 'preset-default' }],
  76. },
  77. },
  78. },
  79. ],
  80. },
  81. );
  82. // Modify the file loader rule to ignore *.svg, since we have it handled now.
  83. fileLoaderRule.exclude = /\.svg$/i;
  84. return config;
  85. },
  86. });