Skip to content

Commit ac11f32

Browse files
author
lijialiang
committed
docs: README
1 parent b9812fa commit ac11f32

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ try {
195195
}
196196
```
197197

198+
## TypeScript 声明 SVGA 文件
199+
200+
```ts
201+
// global.d.ts
202+
declare module '*.svga'
203+
```
204+
198205
## Webpack SVGA
199206
200207
SVGA 文件可用 [url-loader](https://www.npmjs.com/package/raw-loader) 配置 Webpack 进行打包构建,例如:
@@ -214,9 +221,28 @@ module.exports = {
214221

215222
// js
216223
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'
218244
const parser = new Parser()
219-
const svga = await parser.load(XX)
245+
const svga = await parser.load(xx)
220246
```
221247

222248
## [VSCode Plugin SVGA Preview](https://marketplace.visualstudio.com/items?itemName=svga-perview.svga-perview)

0 commit comments

Comments
 (0)