Skip to content

Commit

Permalink
refactor: Add error message for <% preact.(head|body)End %>
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Jan 7, 2023
1 parent e96fa98 commit 50439be
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/cli/src/lib/webpack/render-html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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+%>/,
Expand Down

0 comments on commit 50439be

Please sign in to comment.