From 9cb174da17c98f27068d73d2590bc4cba1898f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=A3=8E?= <244732635@qq.com> Date: Sat, 2 Jun 2018 23:35:02 +0800 Subject: [PATCH] feat: shouldPrefetch option for bundleRenderer (close: #463) (#514) --- docs/config/README.md | 7 +++++++ docs/zh/config/README.md | 7 +++++++ lib/build.js | 1 + 3 files changed, 15 insertions(+) diff --git a/docs/config/README.md b/docs/config/README.md index 14e5c827df..65e3b91c1f 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -109,6 +109,13 @@ Also, only enable this if you are able to deploy your site with SSL, since servi Specify locales for i18n support. For more details, see the guide on [Internationalization](../guide/i18n.md). +### shouldPrefetch + +- Type: `Function` +- Default: `() => true` + +A function to control what files should have `` resource hints generated. See [shouldPrefetch](https://ssr.vuejs.org/api/#shouldprefetch). + ## Theming ### theme diff --git a/docs/zh/config/README.md b/docs/zh/config/README.md index 3ce18b91ac..bf756d1395 100644 --- a/docs/zh/config/README.md +++ b/docs/zh/config/README.md @@ -108,6 +108,13 @@ module.exports = { 提供多语言支持的语言配置。具体细节请查看 [多语言支持](../guide/i18n.md)。 +### shouldPrefetch + +- 类型: `Function` +- 默认值: `() => true` + +一个函数,用来控制对于哪些文件,是需要生成 `` 资源提示的。请参考 [shouldPrefetch](https://ssr.vuejs.org/zh/api/#shouldpreload)。 + ## 主题 ### theme diff --git a/lib/build.js b/lib/build.js index 9587da5542..33003a01c4 100644 --- a/lib/build.js +++ b/lib/build.js @@ -56,6 +56,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) { clientManifest, runInNewContext: false, inject: false, + shouldPrefetch: options.siteConfig.shouldPrefetch || (() => true), template: await fs.readFile(path.resolve(__dirname, 'app/index.ssr.html'), 'utf-8') })