mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
- Based on - https://github.com/storybookjs/storybook/tree/next/code/frameworks/nextjs - https://storybook.js.org/blog/integrate-nextjs-and-storybook-automatically/
26 lines
653 B
Plaintext
26 lines
653 B
Plaintext
```js
|
|
// .storybook/main.js
|
|
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'));
|
|
if (imageRule) {
|
|
imageRule['exclude'] = /\.svg$/;
|
|
}
|
|
|
|
// Configure .svg files to be loaded with @svgr/webpack
|
|
config.module.rules.push({
|
|
test: /\.svg$/,
|
|
use: ['@svgr/webpack'],
|
|
});
|
|
|
|
return config;
|
|
},
|
|
};
|
|
```
|