-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js.txt
41 lines (37 loc) · 1.12 KB
/
server.js.txt
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
32
33
34
35
36
37
38
39
40
41
const bs = require('browser-sync').create();
// Options passed to Chokidar
bs.init({
watchOptions: {
ignoreInitial: true,
ignored: ['*.txt', '**/dist/**', '**/node_modules/**']
},
files: ['./src'],
// Serve files from the current directory
server: true,
port: 8080
});
// const { path, fs } = require('sbg-utility');
// const express = require('express');
// const app = express();
// // serve static files
// const staticPaths = [path.join(__dirname, 'dist'), __dirname];
// staticPaths
// .filter(dir => fs.existsSync(dir))
// .map(dir => {
// return {
// dir,
// files: fs.readdirSync(dir).map(file => path.join(dir, file))
// };
// })
// .flat()
// .forEach(o => {
// const pathname = o.dir.replace(path.toUnix(__dirname), '');
// console.log('register static', pathname, '->', o.dir);
// app.use(pathname, express.static(o.dir));
// app.use(express.static(o.dir));
// });
// const server = app.listen(4000, function () {
// const host = 'localhost';
// const port = server.address().port;
// console.log('listening on http://' + host + ':' + port + '/');
// });