File tree 3 files changed +13
-14
lines changed
3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.1.2
4
+
5
+ Use only ` load ` to skip source maps
6
+
3
7
## 0.1.1
4
8
5
9
Fix build issue with empty source maps
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vite-plugin-fast-react-svg" ,
3
3
"description" : " Turn SVG into React components, without Babel" ,
4
- "version" : " 0.1.1 " ,
4
+ "version" : " 0.1.2 " ,
5
5
"license" : " MIT" ,
6
6
"author" : " Arnaud Barré (https://github.com/ArnaudBarre)" ,
7
7
"main" : " dist/index.js" ,
Original file line number Diff line number Diff line change @@ -6,26 +6,21 @@ export default function svgPlugin(): Plugin {
6
6
return {
7
7
name : "svg" ,
8
8
enforce : "pre" ,
9
- load ( id ) {
9
+ async load ( id ) {
10
10
if ( id . endsWith ( ".svg" ) ) {
11
- return readFileSync ( id , "utf-8" ) ;
12
- }
13
- if ( id . endsWith ( ".svg?inline" ) ) {
14
- return readFileSync ( id . replace ( "?inline" , "" ) , "utf-8" ) ;
15
- }
16
- } ,
17
- async transform ( svg , id ) {
18
- if ( id . endsWith ( ".svg" ) ) {
19
- const { code, warnings } = await transform ( svgToJSX ( svg ) , {
20
- loader : "jsx" ,
21
- } ) ;
11
+ const { code, warnings } = await transform (
12
+ svgToJSX ( readFileSync ( id , "utf-8" ) ) ,
13
+ { loader : "jsx" }
14
+ ) ;
22
15
for ( const warning of warnings ) {
23
16
console . log ( warning . location , warning . text ) ;
24
17
}
25
18
return code ;
26
19
}
27
20
if ( id . endsWith ( ".svg?inline" ) ) {
28
- const base64 = Buffer . from ( svg ) . toString ( "base64" ) ;
21
+ const base64 = Buffer . from (
22
+ readFileSync ( id . replace ( "?inline" , "" ) , "utf-8" )
23
+ ) . toString ( "base64" ) ;
29
24
return `export default "data:image/svg+xml;base64,${ base64 } "` ;
30
25
}
31
26
} ,
You can’t perform that action at this time.
0 commit comments