diff --git a/code/frameworks/nextjs/README.md b/code/frameworks/nextjs/README.md index d15ad4d4a98a..4d9ea8542470 100644 --- a/code/frameworks/nextjs/README.md +++ b/code/frameworks/nextjs/README.md @@ -827,10 +827,15 @@ Below is an example of how to add svgr support to Storybook with this framework. export default { // ... webpackFinal: async (config) => { + config.module = config.module || {}; + config.module.rules = config.module.rules || []; + // This modifies the existing image rule to exclude .svg files // since you want to handle those files with @svgr/webpack - const imageRule = config.module.rules.find((rule) => rule.test.test('.svg')); - imageRule.exclude = /\.svg$/; + const imageRule = config.module.rules.find((rule) => rule?.['test']?.test('.svg')); + if (imageRule) { + imageRule['exclude'] = /\.svg$/; + } // Configure .svg files to be loaded with @svgr/webpack config.module.rules.push({