File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,13 @@ try {
195
195
}
196
196
```
197
197
198
+ ## TypeScript 声明 SVGA 文件
199
+
200
+ ``` ts
201
+ // global.d.ts
202
+ declare module ' *.svga'
203
+ ` ` `
204
+
198
205
## Webpack SVGA
199
206
200
207
SVGA 文件可用 [url-loader](https://www.npmjs.com/package/raw-loader) 配置 Webpack 进行打包构建,例如:
@@ -214,9 +221,28 @@ module.exports = {
214
221
215
222
// js
216
223
import { Parser } from ' svga'
217
- import XX from ' ./xx.svga'
224
+ import xx from ' ./xx.svga'
225
+ const parser = new Parser ()
226
+ const svga = await parser .load (xx )
227
+ ```
228
+
229
+ ## Vite SVGA
230
+
231
+ SVGA 文件可通过配置 Vite 作为 [ 静态资源] ( https://vitejs.dev/guide/assets.html#explicit-url-imports ) 打包构建,例如:
232
+
233
+ ``` js
234
+ // vite.config.ts
235
+ export default defineConfig ({
236
+ assetsInclude: [
237
+ ' svga'
238
+ ]
239
+ })
240
+
241
+ // js
242
+ import { Parser } from ' svga'
243
+ import xx from ' ./xx.svga?url'
218
244
const parser = new Parser ()
219
- const svga = await parser .load (XX )
245
+ const svga = await parser .load (xx )
220
246
```
221
247
222
248
## [ VSCode Plugin SVGA Preview] ( https://marketplace.visualstudio.com/items?itemName=svga-perview.svga-perview )
You can’t perform that action at this time.
0 commit comments