Skip to content

Commit

Permalink
docs: add tip for handling webpack assets base
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Dec 20, 2023
1 parent 7c79898 commit 679b8e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/guide/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ In most cases, you don't need to worry about the reference path of those public
![VuePress Logo](/images/hero.png)
```

::: tip
When using [webpack bundler](../reference/bundler/webpack.md), you need to set [markdown.assets.absolutePathPrependBase](../reference/config.md#markdown-assets) to `true` to automatically prepend base to markdown images.
:::

However, sometimes you may have some dynamical links referencing public files, especially when you are authoring a custom theme. In such case, the `base` could not be handled automatically. To help with that, VuePress provides a [withBase](../reference/client-api.md#withbase) helper to prepend `base` for you:

```vue
Expand Down
4 changes: 4 additions & 0 deletions docs/zh/guide/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
![VuePress Logo](/images/hero.png)
```

::: tip
在使用 [Webpack 打包工具](../reference/bundler/webpack.md) 时,你需要将 [markdown.assets.absolutePathPrependBase](../reference/config.md#markdown-assets) 设置为 `true` 来给 Markdown 图片自动添加 `base` 前缀。
:::

然而,有些情况下,你可能会有一些指向 Public 文件的动态路径,尤其是在你开发一个自定义主题的时候。在这种情况下, `base` 无法被自动处理。为了解决这个问题,VuePress 提供了 [withBase](../reference/client-api.md#withbase) 工具函数,它可以帮助你添加 `base` 前缀:

```vue
Expand Down

0 comments on commit 679b8e8

Please sign in to comment.