-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·45 lines (35 loc) · 1.13 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var webpack = require('webpack');
var WebpackConfig = require("webpack-config");
var path = require("path");
module.exports = {
start: function(prodMode) {
var env = {
production: process.env.NODE_ENV === 'production' || prodMode
};
if (!env.production) {
var config = new WebpackConfig().extend('webpack.dev.config');
var WebpackDevServer = require('webpack-dev-server');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(3000, 'localhost', function (err, result) {
if (err) {
console.log(err);
}
console.log('Listening at localhost:3000');
});
} else {
var express = require('express');
var app = express();
app.use("/static",express.static(__dirname + '/dist'));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, "index.html"));
});
var port = Number(process.env.PORT || 3000);
app.listen(port, function () {
console.log('server running at localhost:3000, go refresh and see magic');
});
}
}
}