Skip to content

Commit

Permalink
switched to minimal live reload server.
Browse files Browse the repository at this point in the history
  • Loading branch information
OurCodeBase committed Oct 23, 2024
1 parent a9cff32 commit cce10b8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ To know about the project structure read about files included in this code block
- Excellent terminal user interface ✅
- Post this project to npmjs website. ✅
- Add Tailwind CSS support. ✅
- Use a lightweight server for EJS live reloading.
- Use a lightweight server for EJS live reloading.
- Prompt `package.json` file's details from user. ⏩
- Custom local template feature ⏩

Expand Down
2 changes: 1 addition & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ To know about the project structure read about files included in this code block
- Excellent terminal user interface ✅
- Post this project to npmjs website. ✅
- Add Tailwind CSS support. ✅
- Use a lightweight server for EJS live reloading.
- Use a lightweight server for EJS live reloading.
- Prompt `package.json` file's details from user. ⏩
- Custom local template feature ⏩

Expand Down
18 changes: 16 additions & 2 deletions tailwind/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ const express = require('express')
const app = express()
const port = 3000

/**
* Code snippet for hot reloadings.
* You can wipe this at production.
*/
const livereload = require("livereload")
const connectlivereload = require("connect-livereload")
app.use(connectlivereload())
const livereloadserver = livereload.createServer()
livereloadserver.watch(path.join(__dirname, "views"))
livereloadserver.watch(path.join(__dirname, "public"))
livereloadserver.server.once("connection", () => {
setTimeout(() => livereloadserver.refresh("/"), 100)
})

app.set('view engine', 'ejs')
app.set('views', path.join(__dirname, 'views'))
app.use(express.static('public'))
Expand All @@ -20,8 +34,8 @@ app.get('/', (req, res) => res.render('home'))

app.listen(port, () => {
/**
* The above code is exclusivly for dev purpose.
* You can replace this function.
* Code snippet for dev purpose.
* You can wipe this at production.
*/
const netface = require('./utils/netface')
const linkfaces = netface.ipv4s()
Expand Down
3 changes: 2 additions & 1 deletion tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
},
"devDependencies": {
"nodemon": "^3.1.7",
"livereload": "^0.9.3",
"connect-livereload": "^0.6.1",
"npm-run-all2": "^7.0.0",
"browser-sync": "^3.0.3",
"tailwindcss": "^3.4.13"
}
}
18 changes: 16 additions & 2 deletions template/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ const express = require('express')
const app = express()
const port = 3000

/**
* Code snippet for hot reloadings.
* You can wipe this at production.
*/
const livereload = require("livereload")
const connectlivereload = require("connect-livereload")
app.use(connectlivereload())
const livereloadserver = livereload.createServer()
livereloadserver.watch(path.join(__dirname, "views"))
livereloadserver.watch(path.join(__dirname, "public"))
livereloadserver.server.once("connection", () => {
setTimeout(() => livereloadserver.refresh("/"), 100)
})

app.set('view engine', 'ejs')
app.use(express.static('public'))
app.use('/colors', express.static(
Expand All @@ -19,8 +33,8 @@ app.get('/', (req, res) => res.render('home'))

app.listen(port, () => {
/**
* The above code is exclusivly for dev purpose.
* You can replace this function.
* Code snippet for dev purpose.
* You can wipe this at production.
*/
const netface = require('./utils/netface')
const linkfaces = netface.ipv4s()
Expand Down
5 changes: 3 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"devDependencies": {
"nodemon": "^3.1.7",
"npm-run-all2": "^7.0.0",
"browser-sync": "^3.0.3"
"livereload": "^0.9.3",
"connect-livereload": "^0.6.1",
"npm-run-all2": "^7.0.0"
}
}

0 comments on commit cce10b8

Please sign in to comment.