-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
49 lines (42 loc) · 1.18 KB
/
server.js
File metadata and controls
49 lines (42 loc) · 1.18 KB
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
46
47
48
49
var path = require("path"),
express = require('express'),
app = express(),
dev = false;
process.argv.forEach(function (val, index, array) {
if(val == "--development")
{
dev = true;
}
});
if(dev)
{
var webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server'),
config = require('./webpack.config');
var server = new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
}
});
server.use('/', function(req, res) {
res.sendFile(path.join(__dirname+'/index.html'));
});
server.listen(3003, 'localhost', function (err, result) {
if (err) {
console.log(err);
}
console.log('Running at http://localhost:3003');
});
}
else
{
app.use('/', express.static('dist'));
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.listen(3003, function () {
console.log('Running at http://localhost:3003');
});
}