Skip to content

Commit

Permalink
fix: Ensure processing prerenderUrls fails build rather than warn (#1785
Browse files Browse the repository at this point in the history
)

* fix: If prerenderUrls exists but cannot be read, it should error

* docs: Adding changeset
  • Loading branch information
rschristian authored Mar 15, 2023
1 parent c55a69a commit a4968ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-pans-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

If `--prerenderUrls` file exists on the disk, but it cannot be processed (thrown errors, incorrect format, etc), the build should error out rather than continue with a warning.
13 changes: 7 additions & 6 deletions packages/cli/src/lib/webpack/render-html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plug
const HtmlWebpackPlugin = require('html-webpack-plugin');
const prerender = require('./prerender');
const createLoadManifest = require('./create-load-manifest');
const { esmImport, tryResolveConfig, warn } = require('../../util');
const { error, esmImport, tryResolveConfig, warn } = require('../../util');

const PREACT_FALLBACK_URL = '/200.html';

Expand Down Expand Up @@ -126,11 +126,12 @@ module.exports = async function (config) {
if (Array.isArray(result)) {
pages = result;
}
} catch (error) {
warn(
`Failed to load prerenderUrls file, using default!\n${
config.verbose ? error.stack : error.message
}`
} catch (err) {
error(
`Failed to load prerenderUrls file!\n${
config.verbose ? err.stack : err.message
}`,
1
);
}
}
Expand Down

0 comments on commit a4968ee

Please sign in to comment.