Skip to content

Commit f9fb9f0

Browse files
committed
feat: control BundleRenderer shouldPrefetch option (vuejs#463)
1 parent d53807e commit f9fb9f0

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/config/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ Also, only enable this if you are able to deploy your site with SSL, since servi
105105

106106
Specify locales for i18n support. For more details, see the guide on [Internationalization](../guide/i18n.md).
107107

108+
### shouldPrefetch
109+
110+
- Type: `Function`
111+
- Default: `() => true`
112+
113+
A function to control what files should have `<link rel="preload">` resource hints generated. See [shouldPrefetch](https://ssr.vuejs.org/api/#shouldprefetch).
114+
108115
## Theming
109116

110117
### theme

docs/zh/config/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ module.exports = {
104104

105105
提供多语言支持的语言配置。具体细节请查看 [多语言支持](../guide/i18n.md)
106106

107+
### shouldPrefetch
108+
109+
- 类型: `Function`
110+
- 默认值: `() => true`
111+
112+
一个函数,用来控制对于哪些文件,是需要生成 `<link rel="prefetch">` 资源提示的。请参考 [shouldPrefetch](https://ssr.vuejs.org/zh/api/#shouldpreload)
113+
107114
## 主题
108115

109116
### theme

lib/build.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
5656
clientManifest,
5757
runInNewContext: false,
5858
inject: false,
59+
shouldPrefetch: options.siteConfig.shouldPrefetch || (() => true),
5960
template: await fs.readFile(path.resolve(__dirname, 'app/index.ssr.html'), 'utf-8')
6061
})
6162

0 commit comments

Comments
 (0)