You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default the loader outputs ES2015 and JSX code and should be transpiled with babel or any other transpiler that supports ES2015 and JSX.
40
+
By default the loader outputs ES2015 code (with JSX compiled to JavaScript using babel-preset-react). You can combine it with babel-loader to compile it down to ES5.
41
41
42
42
```js
43
43
// In your webpack config
44
44
{
45
45
test:/\.svg$/,
46
-
loader:'babel!react-svg'
46
+
loaders: [
47
+
{
48
+
loader:'babel',
49
+
query: {
50
+
presets: ['es2015']
51
+
}
52
+
},
53
+
{
54
+
loader:'react-svg',
55
+
query: {
56
+
jsx:true
57
+
}
58
+
}
59
+
]
47
60
}
48
61
```
49
62
50
-
### ES5 output
51
-
52
-
Pass loader query `es5=true`.
63
+
### JSX output
53
64
54
-
Note: babel transform is applied with `react` and `es2015-loose` presets.
65
+
Pass loader query `jsx=true`.
55
66
56
67
```js
57
68
// In your webpack config
58
69
{
59
70
test:/\.svg$/,
60
-
loader:'react-svg?es5=1'
71
+
loader:'react-svg?jsx=1'
61
72
}
62
73
```
63
74
@@ -70,7 +81,6 @@ Note: babel transform is applied with `react` and `es2015-loose` presets.
70
81
test:/\.svg$/,
71
82
loader:'react-svg',
72
83
query: {
73
-
es5:true,
74
84
svgo: {
75
85
// svgo options
76
86
plugins: [{removeTitle:false}],
@@ -258,8 +268,8 @@ in the **SAME directory** as the files
258
268
259
269
### CLI Options
260
270
261
-
+`-5` | `--es5`: Transforms ES2015+JSX output to ES5 using `presets=[es2015-loose, react]`
262
-
+`-0` | `--stdout`: Outputs to STDOUT
271
+
+`--jsx`: Outputs JSX code instead of compiling it to JavaScript using babel-preset-react
0 commit comments