-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver-user.js
executable file
·64 lines (57 loc) · 1.69 KB
/
server-user.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var express = require("express");
var webpackDevMiddleware = require("webpack-dev-middleware");
var webpack = require("webpack");
var path = require("path")
var http = require('http');
var app = express();
var port = process.argv[3]
// var configDir = path.resolve('./', process.argv[5])
// console.log(configDir)
// var webpackConfig = require(configDir)
var webpackConfig = require('./user.webpack.config');
var compiler = webpack(webpackConfig);
// var httpServer
var httpServer = http.createServer(app)
var webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, {
// lazy: true,
hot: true,
stats: { colors: true, chunks: false },
publicPath: "/"
})
app.use(webpackDevMiddlewareInstance);
app.use(require('webpack-hot-middleware')(compiler));
app.use(function (req, res, next) {
// console.log('Time: %d', Date.now());
// console.log(req.hostname)
console.log(req.originalUrl)
// console.log(req.params)
console.log(req.method)
if(req.originalUrl == '/stopProj'){
console.log(222)
// httpServer.close(function(){
httpServer.close()
process.exit();
// });
}else{
next();
}
});
httpServer.listen(port);
// httpServer = http.createServer(app).listen(port);
// var server = app.listen(port, function () {
// console.log(`Listening on port ${port}!`);
// });
// const webpack = require('webpack');
// const WebpackDevServer = require('webpack-dev-server');
// const webpackConfig = require('./webpack.config')
//
// var bundler = new WebpackDevServer(webpack(webpackConfig), {
// publicPath: '/dist/',
// inline: true,
// hot: true,
// quiet: false,
// noInfo: true,
// stats: {colors: true}
// });
//
// bundler.listen(3001, 'localhost');