Skip to content

Commit

Permalink
fix(eleventyConfig): read 404.html on demand (google#166)
Browse files Browse the repository at this point in the history
In the old behaviour, when the user changes the content of `404.md`, they would need to restart the dev server in order for the change to take effect.
This change effectively fixes the issue.
  • Loading branch information
BirkhoffLee authored Feb 10, 2023
1 parent d61d399 commit 20b9de6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,9 @@ module.exports = function (eleventyConfig) {
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function (err, browserSync) {
const content_404 = fs.readFileSync("_site/404.html");

browserSync.addMiddleware("*", (req, res) => {
// Provides the 404 content without redirect.
res.write(content_404);
res.write(fs.readFileSync("_site/404.html"));
res.end();
});
},
Expand Down

0 comments on commit 20b9de6

Please sign in to comment.