From 50439becf220b4a01f84ba43e886cd9025f45e5a Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Sat, 7 Jan 2023 09:01:04 -0600 Subject: [PATCH] refactor: Add error message for <% preact.(head|body)End %> --- packages/cli/src/lib/webpack/render-html-plugin.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/lib/webpack/render-html-plugin.js b/packages/cli/src/lib/webpack/render-html-plugin.js index 44487125f..49f7a8589 100644 --- a/packages/cli/src/lib/webpack/render-html-plugin.js +++ b/packages/cli/src/lib/webpack/render-html-plugin.js @@ -8,7 +8,7 @@ const { } = require('html-webpack-skip-assets-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const prerender = require('./prerender'); -const { esmImport, tryResolveConfig, warn } = require('../../util'); +const { esmImport, error, tryResolveConfig, warn } = require('../../util'); const PREACT_FALLBACK_URL = '/200.html'; @@ -52,6 +52,16 @@ module.exports = async function renderHTMLPlugin(config, env) { } let templateContent = await readFile(templatePath, 'utf-8'); + if (/preact\.(?:headEnd|bodyEnd)/.test(templateContent)) { + const message = ` + '<% preact.headEnd %>' and '<% preact.bodyEnd %>' are no longer supported in CLI v4! + You can copy the new default 'template.ejs' from the following link or adapt your existing: + + https://github.com/preactjs/preact-cli/blob/master/packages/cli/src/resources/template.ejs + `; + + error(message.trim().replace(/^\t+/gm, '') + '\n'); + } if (/preact\.title/.test(templateContent)) { templateContent = templateContent.replace( /<%[=]?\s+preact\.title\s+%>/,