Skip to content

Commit

Permalink
Merge pull request #23621 from storybookjs/yann/fix-nextjs-docs-snippet
Browse files Browse the repository at this point in the history
Documentation: Fix svgr snippet in Next.js docs
  • Loading branch information
yannbf authored Aug 15, 2023
2 parents 45b42f1 + a99dc70 commit 9366791
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions code/frameworks/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 9366791

Please sign in to comment.