Skip to content

Commit 434ec92

Browse files
authored
docs: add dynamic asset prefix guide (#4760)
1 parent 472319b commit 434ec92

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

website/docs/en/config/dev/asset-prefix.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ The differences from the native configuration are as follows:
122122
- `dev.assetPrefix` default value is the same as [server.base](/config/server/base).
123123
- `dev.assetPrefix` automatically appends a trailing `/` by default.
124124
- The value of `dev.assetPrefix` is written to the [process.env.ASSET_PREFIX](/guide/advanced/env-vars#processenvasset_prefix) environment variable (can only be accessed in client code).
125+
126+
## Dynamic asset prefix
127+
128+
Use the `__webpack_public_path__` variable provided by Rspack to dynamically set the URL prefix of static assets in JavaScript code.
129+
130+
See [Rspack - Dynamically set publicPath](https://rspack.dev/config/output#dynamically-set-publicpath).

website/docs/en/config/output/asset-prefix.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ The differences from the native configuration are as follows:
8989
- `output.assetPrefix` default value is the same as [server.base](/config/server/base).
9090
- `output.assetPrefix` automatically appends a trailing `/` by default.
9191
- The value of `output.assetPrefix` is written to the [process.env.ASSET_PREFIX](/guide/advanced/env-vars#processenvasset_prefix) environment variable (can only be accessed in client code).
92+
93+
## Dynamic asset prefix
94+
95+
Use the `__webpack_public_path__` variable provided by Rspack to dynamically set the URL prefix of static assets in JavaScript code.
96+
97+
See [Rspack - Dynamically set publicPath](https://rspack.dev/config/output#dynamically-set-publicpath).

website/docs/zh/config/dev/asset-prefix.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ assetPrefix 可以设置为以下类型的路径:
122122
- `dev.assetPrefix` 默认值与 [server.base](/config/server/base) 相同。
123123
- `dev.assetPrefix` 默认会自动补全尾部的 `/`
124124
- `dev.assetPrefix` 的值会写入 [process.env.ASSET_PREFIX](/guide/advanced/env-vars#processenvasset_prefix) 环境变量(只能在 client 代码中访问)。
125+
126+
## 动态 asset prefix
127+
128+
使用 Rspack 提供的 `__webpack_public_path__` 变量,可以在 JavaScript 代码中动态设置静态资源 URL 的前缀。
129+
130+
详见 [Rspack - 动态设置 publicPath](https://rspack.dev/zh/config/output#%E5%8A%A8%E6%80%81%E8%AE%BE%E7%BD%AE-publicpath)

website/docs/zh/config/output/asset-prefix.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ assetPrefix 可以设置为以下类型的路径:
8989
- `output.assetPrefix` 默认值与 [server.base](/config/server/base) 相同。
9090
- `output.assetPrefix` 默认会自动补全尾部的 `/`
9191
- `output.assetPrefix` 的值会写入 [process.env.ASSET_PREFIX](/guide/advanced/env-vars#processenvasset_prefix) 环境变量(只能在 client 代码中访问)。
92+
93+
## 动态 asset prefix
94+
95+
使用 Rspack 提供的 `__webpack_public_path__` 变量,可以在 JavaScript 代码中动态设置静态资源 URL 的前缀。
96+
97+
详见 [Rspack - 动态设置 publicPath](https://rspack.dev/zh/config/output#%E5%8A%A8%E6%80%81%E8%AE%BE%E7%BD%AE-publicpath)

0 commit comments

Comments
 (0)