Skip to content

Commit 9cb174d

Browse files
LinFeng1997ulivz
authored andcommitted
feat: shouldPrefetch option for bundleRenderer (close: #463) (#514)
1 parent 3b5991f commit 9cb174d

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
@@ -109,6 +109,13 @@ Also, only enable this if you are able to deploy your site with SSL, since servi
109109

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

112+
### shouldPrefetch
113+
114+
- Type: `Function`
115+
- Default: `() => true`
116+
117+
A function to control what files should have `<link rel="preload">` resource hints generated. See [shouldPrefetch](https://ssr.vuejs.org/api/#shouldprefetch).
118+
112119
## Theming
113120

114121
### theme

docs/zh/config/README.md

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

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

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

113120
### 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)