-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-module.js
39 lines (30 loc) · 1.17 KB
/
run-module.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
function run(host, port, dev, callback) {
var options = {};
var fs = require("fs");
var express = require("express");
var path = require("path");
if (dev) {
// DEV MODE DOESN'T USE THE BUNDLED VERSION
options = {
index: "index-dev.html"
};
}
// run webpack to keep the bundle files updated
var webpack = require("webpack");
var config = require(__dirname + "/webpack.config.js");
var compiler = webpack(config);
compiler.run(function (err, stats) {
var expr = express();
expr.use("/", express.static(__dirname, options)); //use static files in ROOT/public folder
expr.use("/site/", express.static(path.join(__dirname, "site"), {index: "index.html"}));
expr.use("/modules/", express.static(path.join(__dirname, "modules"), {index: "index.html"}));
expr.get("/", function (request, response) { //root dir
console.log(request, response);
});
console.log("Your webserver is listening on " + host + ":" + port);
expr.listen(port, host, callback);
compiler.watch({}, function (err, stats) {
});
});
}
module.exports = run;