-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (27 loc) · 683 Bytes
/
server.js
File metadata and controls
31 lines (27 loc) · 683 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
26
27
28
29
30
31
const http = require("http");
const express = require("express");
const fs = require("fs");
const path = require("path");
const sass = require("sass");
const host = "localhost";
const port = 8000;
const app = express();
app.use(express.static("."));
sass.render(
{
file: "stylesheets/style.scss",
},
function (error, result) {
if (error) {
return;
}
fs.writeFile("stylesheets/style.css", result.css, () => {});
}
);
app.use("/", function (_req, res) {
res.sendFile(path.join(__dirname + "/index.html"));
});
const server = http.createServer(app);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
});