forked from StateVoicesNational/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
54 lines (48 loc) · 1.4 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
46
47
48
49
50
51
52
53
54
import WebpackDevServer from "webpack-dev-server";
import webpack from "webpack";
import config from "./config";
import { log } from "../src/lib";
const webpackPort = process.env.WEBPACK_PORT || 3000;
const appPort = process.env.DEV_APP_PORT;
const webpackHost = process.env.WEBPACK_HOST || "127.0.0.1";
Object.keys(config.entry).forEach(key => {
config.entry[key].unshift(
`webpack-dev-server/client?http://${webpackHost}:${webpackPort}/`
);
config.entry[key].unshift("webpack/hot/only-dev-server");
});
const compiler = webpack(config);
const connstring = `http://127.0.0.1:${appPort}`;
log.info(`Proxying requests to:${connstring}`);
const app = new WebpackDevServer(compiler, {
contentBase: "/assets/",
publicPath: "/assets/",
hot: true,
// this should be temporary until we get the real hostname plugged in everywhere
disableHostCheck: true,
headers: { "Access-Control-Allow-Origin": "*" },
proxy: {
"*": `http://127.0.0.1:${appPort}`
},
stats: {
colors: true,
hash: false,
version: false,
timings: false,
assets: false,
chunks: false,
modules: false,
reasons: false,
children: false,
source: false,
errors: false,
errorDetails: false,
warnings: true,
publicPath: false
}
});
app.listen(webpackPort || process.env.PORT, () => {
log.info(
`Webpack dev server is now running on http://${webpackHost}:${webpackPort}`
);
});