Build failed in Storybook webpack config caused by svgr #967
Unanswered
1D1D1D1D1D1D
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
**This error occurs when launching storybook, all svg that i use in the application cause an error in ./src/shared/assets/icons/about-20-20.svg ...etc
Module build failed (from ./node_modules/@svgr/webpack/dist/index.js):
If i remove all references to svg from the application, then all components in the storybook work correctly
webpack.config.ts **
import { buildCssLoader } from '../build/loaders/buildCssLoader';import { BuildPaths } from '../build/types/config';import path from "path";import webpack, { RuleSetRule } from "webpack";export default ({ config }: {config: webpack.Configuration}) => {const paths: BuildPaths = {build: '',html: '',entry: '',src: path.resolve(__dirname, '..', '..', 'src'),};config.resolve.modules.push(paths.src);config.resolve.extensions.push('.ts', '.tsx');config.module.rules = config.module.rules.map((rule: RuleSetRule) => {if (/svg/.test(rule.test as string)) {return { ...rule, exclude: /\.svg$/i };}return rule;});config.module.rules.push({test: /\.svg$/,use: ['@svgr/webpack'],});config.module.rules.push(buildCssLoader(true));return config;};Beta Was this translation helpful? Give feedback.
All reactions