Skip to content

Commit ed0e519

Browse files
committed
tailwindcss boilerplate is now added to gen3-express.
1 parent c169225 commit ed0e519

File tree

10 files changed

+116
-4
lines changed

10 files changed

+116
-4
lines changed

bin/gen3-express.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const signale = require('signale')
77
const { program } = require('commander')
88

99
// path of template.
10-
const template = path.resolve(__dirname, '../template')
10+
let template = path.resolve(__dirname, '../template')
1111

1212
// change package name of a node package.
1313
// @param {string} name - new name of node package.
@@ -39,8 +39,13 @@ async function create_app(app_name) {
3939
program
4040
.version('1.0.0')
4141
.argument('<app-name>', 'name to create new app.')
42-
.action(async (app_name) => {
42+
.option('-t, --tailwindcss', 'To add tailwindcss files.')
43+
.action(async (app_name, options) => {
4344
signale.time()
45+
if (options.tailwindcss) {
46+
signale.info('You have selected tailwind boilerplate.')
47+
template = path.resolve(__dirname, '../tailwind')
48+
}
4449
// check if folder already exist.
4550
if (!fse.existsSync(app_name)) {
4651
signale.await(`${app_name} app is on the way.`)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailwind/app.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const path = require('path')
2+
const express = require('express')
3+
4+
const app = express()
5+
const port = 3000
6+
7+
app.set('view engine', 'ejs')
8+
app.set('views', path.join(__dirname, 'views'))
9+
app.use(express.static('public'))
10+
app.use('/colors', express.static(
11+
path.join(__dirname,
12+
'node_modules',
13+
'material-dynamic-colors',
14+
'dist',
15+
'cdn'
16+
)
17+
))
18+
19+
app.get('/', (req, res) => res.render('home'))
20+
21+
app.listen(port, () => {
22+
/**
23+
* The above code is exclusivly for dev purpose.
24+
* You can replace this function.
25+
*/
26+
const netface = require('./utils/netface')
27+
const linkfaces = netface.ipv4s()
28+
linkfaces.forEach((face) => {
29+
console.info(`http://${face}:${port}`)
30+
})
31+
})

tailwind/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "express-app",
3+
"version": "1.0.0",
4+
"main": "app.js",
5+
"scripts": {
6+
"server": "nodemon app.js",
7+
"sync": "browser-sync start --config sync.js",
8+
"tailwind": "npx tailwindcss -i public/css/style.css -o public/css/tailwind.css --watch",
9+
"dev": "concurrently --kill-others \"npm run server\" \"npm run sync\" \"npm run tailwind\""
10+
},
11+
"dependencies": {
12+
"ejs": "^3.1.10",
13+
"express": "^4.21.0",
14+
"material-dynamic-colors": "^1.1.2"
15+
},
16+
"devDependencies": {
17+
"nodemon": "^3.1.7",
18+
"concurrently": "^9.0.1",
19+
"browser-sync": "^3.0.3",
20+
"tailwindcss": "^3.4.13"
21+
}
22+
}

tailwind/public/css/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@font-face { font-family: sans; src: url(fonts/sans.woff); }
2+
h1 { font-family: sans; }
3+
@tailwind base;
4+
@tailwind components;
5+
@tailwind utilities;
6+

tailwind/public/fonts/sans.woff

47.7 KB
Binary file not shown.

tailwind/sync.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
proxy: 'http://localhost:3000',
3+
files: ["views/**/*.ejs", "public/**/*.{css,js}"],
4+
port: 3001,
5+
open: false,
6+
notify: false
7+
}

tailwind/tailwind.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ["./views/*.ejs"],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
}
9+

tailwind/utils/netface.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const os = require('os')
2+
3+
/**
4+
* This contains all available ipv4 ip address.
5+
* @returns {Object[]} netfaces - All ipv4 ip address.
6+
* */
7+
const ipv4s = () => {
8+
const netfaces = []
9+
const interfaces = os.networkInterfaces()
10+
for (const key of Object.keys(interfaces)) {
11+
for (const interface of interfaces[key]) {
12+
if (interface.family == 'IPv4'){
13+
netfaces.push(interface.address)
14+
}
15+
}
16+
}
17+
return netfaces
18+
}
19+
20+
module.exports = { ipv4s }

tailwind/views/home.ejs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title></title>
7+
<link href="css/tailwind.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<h1 class="text-3xl font-bold underline m-60">Hello World!</h1>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)