返回 slidev
bundle-remote-assets.md
根目录 / docs / features / bundle-remote-assets.md
1 ---
2 relates:
3 - vite-plugin-remote-assets: https://github.com/antfu/vite-plugin-remote-assets
4 tags: [build]
5 description: |
6 Download and bundle remote assets when building your slides.
7 ---
8
9 # Bundle Remote Assets
10
11 Just like you would do in markdown, you can use images pointing to a remote or local URL.
12
13 For remote assets, the built-in [`vite-plugin-remote-assets`](https://github.com/antfu/vite-plugin-remote-assets) will cache them onto the disk at first run, ensuring instant loading even for large images later on.
14
15 ```md
16 ![Remote Image](https://sli.dev/favicon.png)
17 ```
18
19 For local assets, put them into the [`public` folder](/custom/directory-structure.html#public) and reference them with a **leading slash** (i.e., `/pic.png`, NOT `./pic.png`, which is relative to the working file).
20
21 ```md
22 ![Local Image](/pic.png)
23 ```
24
25 If you want to apply custom sizes or styles, you can convert them to the `<img>` tag:
26
27 ```html
28 <img src="/pic.png" class="m-40 h-40 rounded shadow" />
29 ```
30
30 lines MARKDOWN