File tree 2 files changed +8
-15
lines changed
2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change 1
1
// https://github.com/facebook/create-react-app/blob/0ee4765c39f820e5f4820abf4bf2e47b3324da7f/packages/react-scripts/lib/react-app.d.ts#L47-L56
2
2
// https://github.com/pd4d10/vite-plugin-svgr/pull/56 for preact compatiblility
3
3
4
- declare module "*.svg" {
4
+ declare module "*.svg?react " {
5
5
import * as React from "react" ;
6
6
7
- export const ReactComponent : React . FunctionComponent <
7
+ const ReactComponent : React . FunctionComponent <
8
8
React . ComponentProps < "svg" > & { title ?: string }
9
9
> ;
10
+
11
+ export default ReactComponent ;
10
12
}
Original file line number Diff line number Diff line change @@ -4,27 +4,19 @@ import fs from "fs";
4
4
import type { Plugin } from "vite" ;
5
5
import { transformWithEsbuild } from "vite" ;
6
6
7
- export interface ViteSvgrOptions {
8
- /**
9
- * Export React component as default. Notice that it will overrides
10
- * the default behavior of Vite, which exports the URL as default
11
- *
12
- * @default false
13
- */
14
- exportAsDefault ?: boolean ;
7
+ export interface VitePluginSvgrOptions {
15
8
svgrOptions ?: Config ;
16
9
esbuildOptions ?: Parameters < typeof transformWithEsbuild > [ 2 ] ;
17
10
exclude ?: FilterPattern ;
18
11
include ?: FilterPattern ;
19
12
}
20
13
21
- export default function viteSvgr ( {
22
- exportAsDefault,
14
+ export default function vitePluginSvgr ( {
23
15
svgrOptions,
24
16
esbuildOptions,
25
- include = "**/*.svg" ,
17
+ include = "**/*.svg?react " ,
26
18
exclude,
27
- } : ViteSvgrOptions = { } ) : Plugin {
19
+ } : VitePluginSvgrOptions = { } ) : Plugin {
28
20
const filter = createFilter ( include , exclude ) ;
29
21
const postfixRE = / [ ? # ] .* $ / s;
30
22
@@ -41,7 +33,6 @@ export default function viteSvgr({
41
33
const componentCode = await transform ( svgCode , svgrOptions , {
42
34
filePath,
43
35
caller : {
44
- previousExport : exportAsDefault ? null : code ,
45
36
defaultPlugins : [ jsx ] ,
46
37
} ,
47
38
} ) ;
You can’t perform that action at this time.
0 commit comments