-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (27 loc) · 871 Bytes
/
server.js
File metadata and controls
31 lines (27 loc) · 871 Bytes
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
var express = require('express');
var path = require('path');
var webpack = require('webpack');
var app = express();
var isDevelopment = (process.env.NODE_ENV !== 'production');
var staticPath = path.resolve(__dirname, 'public');
app.use(express.static(staticPath))
. get("/", function(req, res){
res.sendFile('index.html',{
root:staticPath
});
})
.listen(process.env.PORT || 8080, function(err){
if(err){console.log(err)};
console.log("Listening at 8080");
});
if (isDevelopment) {
var config = require('./webpack.config');
var WebpackDevServer = require('webpack-dev-server');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true
}).listen(3000, 'localhost', function (err, result) {
if (err) { console.log(err) }
console.log('Listening at localhost:3000');
});
}