Skip to content

Commit 30e23b2

Browse files
committed
Add page for 404 error
1 parent 6bc9d18 commit 30e23b2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

gulpfile.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { readFileSync } from 'node:fs';
2+
13
import gulp from 'gulp';
24
import plumber from 'gulp-plumber';
35
import { nunjucksCompile } from 'gulp-nunjucks';
@@ -137,6 +139,11 @@ export function startServer () {
137139
cors: true,
138140
notify: false,
139141
ui: false,
142+
}, (err, bs) => {
143+
bs.addMiddleware('*', (req, res) => {
144+
res.write(readFileSync(`${PATH_TO_DIST}404.html`));
145+
res.end();
146+
});
140147
});
141148

142149
watch(`${PATH_TO_SOURCE}**/*.{html,njk}`, series(processMarkup));

source/404.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html class="page" lang="ru">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>404</title>
6+
<meta name="viewport" content="width=device-width,initial-scale=1">
7+
<link rel="stylesheet" href="styles/styles.css">
8+
<script src="scripts/index.js" defer></script>
9+
</head>
10+
<body class="page__body">
11+
<h1>404</h1>
12+
<p>Страница не найдена. <a href="/">Перейти на главную</a>.</p>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)