forked from vuejsdevelopers/vuejs-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (23 loc) · 831 Bytes
/
server.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
require('dotenv').config({ silent: true });
const express = require('express');
const app = express();
const path = require('path');
const fs = require('fs');
const http = require('http');
app.use('/public', express.static(path.join(__dirname, 'public')));
app.get('/', (req, res) => {
let template = fs.readFileSync(path.resolve('./index.html'), 'utf-8');
res.send(template);
});
const server = http.createServer(app);
if (process.env.NODE_ENV === 'development') {
const reload = require('reload');
const reloadServer = reload(app);
require('./webpack-dev-middleware').init(app);
}
server.listen(process.env.PORT, function () {
console.log(`Example app listening on port ${process.env.PORT}!`);
if (process.env.NODE_ENV === 'development') {
require("opn")(`http://localhost:${process.env.PORT}`);
}
});