File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -26,20 +26,20 @@ export default function viteSvgr({
26
26
exclude,
27
27
} : ViteSvgrOptions = { } ) : Plugin {
28
28
const filter = createFilter ( include , exclude ) ;
29
+ const postfixRE = / [ ? # ] .* $ / s;
30
+
29
31
return {
30
32
name : "vite-plugin-svgr" ,
31
33
async transform ( code , id ) {
32
34
if ( filter ( id ) ) {
33
35
const { transform } = await import ( "@svgr/core" ) ;
34
36
const { default : jsx } = await import ( "@svgr/plugin-jsx" ) ;
35
37
36
- const svgCode = await fs . promises . readFile (
37
- id . replace ( / \? .* $ / , "" ) ,
38
- "utf8"
39
- ) ;
38
+ const filePath = id . replace ( postfixRE , "" ) ;
39
+ const svgCode = await fs . promises . readFile ( filePath , "utf8" ) ;
40
40
41
41
const componentCode = await transform ( svgCode , svgrOptions , {
42
- filePath : id ,
42
+ filePath,
43
43
caller : {
44
44
previousExport : exportAsDefault ? null : code ,
45
45
defaultPlugins : [ jsx ] ,
You can’t perform that action at this time.
0 commit comments