2022-11-16 00:14:59 +01:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const next = (phase, { defaultConfig }) => {
|
|
|
|
/**
|
|
|
|
* @type {import('next').NextConfig}
|
|
|
|
*/
|
|
|
|
const nextConfig = {
|
|
|
|
webpack: (config, options) => {
|
2023-08-16 13:43:54 +02:00
|
|
|
// Grab the existing rule that handles SVG imports
|
|
|
|
const fileLoaderRule = config.module.rules.find((rule) =>
|
|
|
|
rule.test?.test?.('.svg')
|
|
|
|
)
|
|
|
|
|
2022-11-16 00:14:59 +01:00
|
|
|
config.module.rules.push(
|
2023-08-16 13:43:54 +02:00
|
|
|
// Reapply the existing rule, but only for svg imports ending in ?url
|
2022-11-16 00:14:59 +01:00
|
|
|
{
|
2023-08-16 13:43:54 +02:00
|
|
|
...fileLoaderRule,
|
|
|
|
test: /\.svg$/i,
|
|
|
|
resourceQuery: /url/ // *.svg?url
|
2022-11-16 00:14:59 +01:00
|
|
|
},
|
2023-08-16 13:43:54 +02:00
|
|
|
// Convert all other *.svg imports to React components
|
2022-11-16 00:14:59 +01:00
|
|
|
{
|
2023-08-16 13:43:54 +02:00
|
|
|
test: /\.svg$/i,
|
2024-02-01 19:59:51 +01:00
|
|
|
issuer: fileLoaderRule.issuer,
|
|
|
|
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
|
2023-08-16 13:43:54 +02:00
|
|
|
use: [{ loader: '@svgr/webpack', options: { icon: true } }]
|
2022-11-16 00:14:59 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-08-16 13:43:54 +02:00
|
|
|
// Modify the file loader rule to ignore *.svg, since we have it handled now.
|
|
|
|
fileLoaderRule.exclude = /\.svg$/i
|
|
|
|
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.gif$/,
|
|
|
|
// yay for webpack 5
|
|
|
|
// https://webpack.js.org/guides/asset-management/#loading-images
|
|
|
|
type: 'asset/resource'
|
|
|
|
})
|
|
|
|
|
2022-11-16 00:14:59 +01:00
|
|
|
return typeof defaultConfig.webpack === 'function'
|
|
|
|
? defaultConfig.webpack(config, options)
|
|
|
|
: config
|
2024-07-26 12:45:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
eslint: {
|
|
|
|
// Using Biome instead of ESLint,
|
|
|
|
// sadly Next.js doesn't have a way to disable ESLint
|
|
|
|
// see https://github.com/vercel/next.js/discussions/59347
|
|
|
|
ignoreDuringBuilds: true
|
2024-02-01 19:59:51 +01:00
|
|
|
}
|
2022-11-16 00:14:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nextConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
export default next
|