-
Notifications
You must be signed in to change notification settings - Fork 0
/
listen-on-port.js
33 lines (30 loc) · 931 Bytes
/
listen-on-port.js
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
// NPM dependencies
const browserSync = require('browser-sync');
// Local dependencies
const server = require('./server.js');
const config = require('./app/config.js');
const utils = require('./lib/utils.js');
// Set up configuration variables
const useBrowserSync = config.useBrowserSync.toLowerCase();
const env = (process.env.NODE_ENV || 'development').toLowerCase();
utils.findAvailablePort(server, function (port) {
console.log(
'Listening on port ' + port + ' url: http://localhost:' + port
);
if (env === 'production' || useBrowserSync === 'false') {
server.listen(port);
} else {
server.listen(port - 50, function () {
browserSync({
proxy: 'localhost:' + (port - 50),
port: port,
ui: false,
files: ['public/**/*.*', 'app/views/**/*.*'],
ghostMode: false,
open: false,
notify: false,
logLevel: 'error',
});
});
}
});