From a10047e6f5f3c9ff2060272696f98dff8590b4de Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 28 Jan 2020 22:08:37 -0500 Subject: [PATCH] Don't emit prerender data script if there is none One thing I haven't checked yet: will this cause prerender-data-provider to attempt to fetch prerender data because there's no script tag? --- packages/cli/lib/lib/webpack/render-html-plugin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/lib/lib/webpack/render-html-plugin.js b/packages/cli/lib/lib/webpack/render-html-plugin.js index 2d08ec179..123c10513 100644 --- a/packages/cli/lib/lib/webpack/render-html-plugin.js +++ b/packages/cli/lib/lib/webpack/render-html-plugin.js @@ -93,7 +93,9 @@ module.exports = async function(config) { return config.prerender ? prerender({ cwd, dest, src }, values) : ''; }, scriptLoading: 'defer', - CLI_DATA: { preRenderData: { url, ...routeData } }, + CLI_DATA: Object.keys(routeData).length + ? { preRenderData: { url, ...routeData } } + : undefined, }); };