-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
25 lines (19 loc) · 702 Bytes
/
Copy pathdev.js
File metadata and controls
25 lines (19 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const express = require("express");
const path = require("path");
const chokidar = require("chokidar");
const app = express();
const PORT = 3000;
app.use(express.static(path.join(__dirname)));
// For clean URLs in dev: /projects, /honk, /blog, /blog/* -> serve index.html
app.get(/^\/(projects|honk|blog|blog\/.+)$/, (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
chokidar.watch(__dirname, { ignored: /node_modules/ }).on("change", (filePath) => {
console.log(`File changed: ${filePath}`);
});
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});