Skip to content

Commit cce10b8

Browse files
committed
switched to minimal live reload server.
1 parent a9cff32 commit cce10b8

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ To know about the project structure read about files included in this code block
8888
- Excellent terminal user interface ✅
8989
- Post this project to npmjs website. ✅
9090
- Add Tailwind CSS support. ✅
91-
- Use a lightweight server for EJS live reloading.
91+
- Use a lightweight server for EJS live reloading.
9292
- Prompt `package.json` file's details from user. ⏩
9393
- Custom local template feature ⏩
9494

docs/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ To know about the project structure read about files included in this code block
9595
- Excellent terminal user interface ✅
9696
- Post this project to npmjs website. ✅
9797
- Add Tailwind CSS support. ✅
98-
- Use a lightweight server for EJS live reloading.
98+
- Use a lightweight server for EJS live reloading.
9999
- Prompt `package.json` file's details from user. ⏩
100100
- Custom local template feature ⏩
101101

tailwind/app.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ const express = require('express')
44
const app = express()
55
const port = 3000
66

7+
/**
8+
* Code snippet for hot reloadings.
9+
* You can wipe this at production.
10+
*/
11+
const livereload = require("livereload")
12+
const connectlivereload = require("connect-livereload")
13+
app.use(connectlivereload())
14+
const livereloadserver = livereload.createServer()
15+
livereloadserver.watch(path.join(__dirname, "views"))
16+
livereloadserver.watch(path.join(__dirname, "public"))
17+
livereloadserver.server.once("connection", () => {
18+
setTimeout(() => livereloadserver.refresh("/"), 100)
19+
})
20+
721
app.set('view engine', 'ejs')
822
app.set('views', path.join(__dirname, 'views'))
923
app.use(express.static('public'))
@@ -20,8 +34,8 @@ app.get('/', (req, res) => res.render('home'))
2034

2135
app.listen(port, () => {
2236
/**
23-
* The above code is exclusivly for dev purpose.
24-
* You can replace this function.
37+
* Code snippet for dev purpose.
38+
* You can wipe this at production.
2539
*/
2640
const netface = require('./utils/netface')
2741
const linkfaces = netface.ipv4s()

tailwind/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
},
1616
"devDependencies": {
1717
"nodemon": "^3.1.7",
18+
"livereload": "^0.9.3",
19+
"connect-livereload": "^0.6.1",
1820
"npm-run-all2": "^7.0.0",
19-
"browser-sync": "^3.0.3",
2021
"tailwindcss": "^3.4.13"
2122
}
2223
}

template/app.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ const express = require('express')
44
const app = express()
55
const port = 3000
66

7+
/**
8+
* Code snippet for hot reloadings.
9+
* You can wipe this at production.
10+
*/
11+
const livereload = require("livereload")
12+
const connectlivereload = require("connect-livereload")
13+
app.use(connectlivereload())
14+
const livereloadserver = livereload.createServer()
15+
livereloadserver.watch(path.join(__dirname, "views"))
16+
livereloadserver.watch(path.join(__dirname, "public"))
17+
livereloadserver.server.once("connection", () => {
18+
setTimeout(() => livereloadserver.refresh("/"), 100)
19+
})
20+
721
app.set('view engine', 'ejs')
822
app.use(express.static('public'))
923
app.use('/colors', express.static(
@@ -19,8 +33,8 @@ app.get('/', (req, res) => res.render('home'))
1933

2034
app.listen(port, () => {
2135
/**
22-
* The above code is exclusivly for dev purpose.
23-
* You can replace this function.
36+
* Code snippet for dev purpose.
37+
* You can wipe this at production.
2438
*/
2539
const netface = require('./utils/netface')
2640
const linkfaces = netface.ipv4s()

template/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
},
1515
"devDependencies": {
1616
"nodemon": "^3.1.7",
17-
"npm-run-all2": "^7.0.0",
18-
"browser-sync": "^3.0.3"
17+
"livereload": "^0.9.3",
18+
"connect-livereload": "^0.6.1",
19+
"npm-run-all2": "^7.0.0"
1920
}
2021
}

0 commit comments

Comments
 (0)