From f9fb9f06f86eb8a4de567636edf4d63655fe227b Mon Sep 17 00:00:00 2001 From: LinFeng1997 <244732635@qq.com> Date: Mon, 28 May 2018 14:45:38 +0800 Subject: [PATCH] feat: control BundleRenderer shouldPrefetch option (#463) --- 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 2135701811..f0c719c5e6 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -105,6 +105,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 eb069e2e1e..c36ff3147e 100644 --- a/docs/zh/config/README.md +++ b/docs/zh/config/README.md @@ -104,6 +104,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') })