From 2c98082c1c233e7f971e4ce2a9208698850d14f2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 13 Sep 2021 00:09:25 +0200 Subject: [PATCH] config refactor --- next.config.js | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/next.config.js b/next.config.js index 498921a..93cfbaf 100644 --- a/next.config.js +++ b/next.config.js @@ -1,30 +1,23 @@ -// eslint-disable-next-line no-unused-vars -const withSvgr = (nextConfig = {}, nextComposePlugins = {}) => { - return Object.assign({}, nextConfig, { - webpack(config, options) { +module.exports = (phase, { defaultConfig }) => { + /** + * @type {import('next').NextConfig} + */ + const nextConfig = { + webpack: (config, options) => { config.module.rules.push({ test: /\.svg$/, - use: [ - { - loader: '@svgr/webpack', - options: { - icon: true - } - } - ] + use: [{ loader: '@svgr/webpack', options: { icon: true } }] }) + return typeof defaultConfig.webpack === 'function' + ? defaultConfig.webpack(config, options) + : config + }, + bundleAnalyzer: () => + require('@next/bundle-analyzer')({ + enabled: process.env.ANALYZE === 'true' + }), + reactStrictMode: true + } - if (typeof nextConfig.webpack === 'function') { - return nextConfig.webpack(config, options) - } - - return config - } - }) + return nextConfig } - -const withBundleAnalyzer = require('@next/bundle-analyzer')({ - enabled: process.env.ANALYZE === 'true' -}) - -module.exports = withSvgr(withBundleAnalyzer())