File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,16 @@ import path from 'node:path';
22import { fileURLToPath } from 'node:url' ;
33import type { RsbuildPlugin , Rspack } from '@rsbuild/core' ;
44import { PLUGIN_REACT_NAME } from '@rsbuild/plugin-react' ;
5- import type { Config as SvgrOptions } from '@svgr/core' ;
5+ import type { Config as BaseSvgrOptions } from '@svgr/core' ;
66import deepmerge from 'deepmerge' ;
77import type { Config as SvgoConfig } from 'svgo' ;
88
9+ // @svgr /core does not have the svgo dependency, so we need to
10+ // manually specify the svgoConfig type
11+ type SvgrOptions = Omit < BaseSvgrOptions , 'svgoConfig' > & {
12+ svgoConfig ?: SvgoConfig ;
13+ } ;
14+
915const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
1016
1117type SvgoPluginConfig = NonNullable < SvgoConfig [ 'plugins' ] > [ 0 ] ;
@@ -156,7 +162,9 @@ export const pluginSvgr = (options: PluginSvgrOptions = {}): RsbuildPlugin => ({
156162
157163 const rule = chain . module . rule ( CHAIN_ID . RULE . SVG ) . test ( SVG_REGEX ) ;
158164
159- const svgrOptions = deepmerge < SvgrOptions > (
165+ const svgrOptions = deepmerge <
166+ SvgrOptions & Pick < Required < SvgrOptions > , 'svgo' | 'svgoConfig' >
167+ > (
160168 {
161169 svgo : true ,
162170 svgoConfig : getSvgoDefaultConfig ( ) ,
You can’t perform that action at this time.
0 commit comments