3
3
This plugin makes it possible to import SVG files as Svelte
4
4
components, inline SVG code or urls.
5
5
6
- _ NOTE! This plugin isn't just for SvelteKit, but works for any Svelte
6
+ > ### ** NOTE!** For ** Svelte 4** projects, use version 4 of this plugin
7
+
8
+ > _ NOTE! This plugin isn't just for SvelteKit, but works for any Svelte
7
9
project using Vite_
8
10
9
11
## Install
@@ -192,8 +194,24 @@ interface Options {
192
194
}
193
195
````
194
196
197
+ ## Typescript
198
+
199
+ For Typescript not to complain about ` file.svg?component ` et.al, add the
200
+ following import statement to ` src/app.d.ts ` (or any ` .d.ts ` file somewhere in the path of your
201
+ project where ` tsc ` can find it).
202
+
203
+ ``` ts
204
+ import ' @poppanator/sveltekit-svg/dist/svg.d.ts'
205
+ ```
206
+
207
+ > ** NOTE!** If you have ` module ` /` moduleResolution ` set to ` NodeNext ` in your
208
+ > Typescript config, you ** MUST** include ` .d.ts ` in the import of the SVG
209
+ > type definition.
210
+
195
211
## Notes on using with _ Jest_
196
212
213
+ _ I don't know if this still applies, but it's kept here for good measure_
214
+
197
215
According to a report [ _ Jest_ ] ( https://jestjs.io/ ) will have trouble
198
216
transforming ` .svg ` files when such is imported as a Svelte component.
199
217
@@ -213,17 +231,3 @@ module.exports = {
213
231
where ` src/lib/EmptyIcon.svelte ` can contain just ` <svg /> ` .
214
232
215
233
> [ See the reported issue and solution] ( https://github.com/poppa/sveltekit-svg/issues/22 )
216
-
217
- ## Typescript
218
-
219
- For Typescript not to complain about ` file.svg?component ` et.al, add the
220
- following import statement to ` src/app.d.ts ` (or any ` .d.ts ` file somewhere in the path of your
221
- project where ` tsc ` can find it).
222
-
223
- ``` ts
224
- import ' @poppanator/sveltekit-svg/dist/svg.d.ts'
225
- ```
226
-
227
- > ** NOTE!** If you have ` module ` /` moduleResolution ` set to ` NodeNext ` in your
228
- > Typescript config, you ** MUST** include ` .d.ts ` in the import of the SVG
229
- > type definition.
0 commit comments