-
Notifications
You must be signed in to change notification settings - Fork 0
/
devServer.js
37 lines (29 loc) · 907 Bytes
/
devServer.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
const path = require("path");
const express = require("express");
const webpack = require("webpack");
const server = process.env.RJSF_DEV_SERVER || "localhost:8080";
const splitServer = server.split(":");
const host = splitServer[0];
const port = splitServer[1];
const env = "dev";
const webpackConfig = require("./webpack.config." + env);
const compiler = webpack(webpackConfig);
const app = express();
app.use(require("webpack-dev-middleware")(compiler, {
publicPath: webpackConfig.output.publicPath,
noInfo: true
}));
app.use(require("webpack-hot-middleware")(compiler));
app.get("/favicon.ico", function(req, res) {
res.status(204).end();
});
app.get("/", function(req, res) {
res.sendFile(path.join(__dirname, "playground", "index.html"));
});
app.listen(port, host, function(err) {
if (err) {
console.log(err);
return;
}
console.log(`Listening at http://${server}`);
});