add chokidar and npm start
This commit is contained in:
parent
a302f52636
commit
9b4cb16669
5 changed files with 249 additions and 9 deletions
26
server.js
Normal file
26
server.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const chokidar = require("chokidar");
|
||||
const handler = require("serve-handler");
|
||||
const http = require("http");
|
||||
|
||||
const build = require("./build");
|
||||
|
||||
chokidar
|
||||
.watch(["style.css", "build.js", "docs", "fonts", "icon"], {
|
||||
usePolling: true,
|
||||
})
|
||||
.on("change", (file) => {
|
||||
console.log(
|
||||
`[${new Date().toLocaleTimeString()}] ${file} changed -- rebuilding...`
|
||||
);
|
||||
build();
|
||||
});
|
||||
|
||||
const server = http.createServer((request, response) => {
|
||||
return handler(request, response, {
|
||||
public: "dist",
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(3000, () => {
|
||||
console.log("Running at http://localhost:3000");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue