UNPKG

963 BJavaScriptView Raw
1const path = require('path');
2const webpack = require('webpack');
3const webpackDevMiddleware = require("webpack-dev-middleware");
4const webpackHotMiddleware = require("webpack-hot-middleware");
5const webpackConfig = require('./webpack.config');
6const express = require("express");
7
8const app = express();
9const compiler = webpack(webpackConfig);
10
11app.set('port', 3000);
12
13app.use(webpackDevMiddleware(compiler, {
14 noInfo: false,
15 quite: false,
16 overlay: false,
17 historyApiFallback: true,
18 stats: {
19 colors: true,
20 entrypoints: true,
21 assets: false,
22 modules: false,
23 children: false,
24 hash: false,
25 moduleTrace: false,
26 }
27}));
28app.use(webpackHotMiddleware(compiler, {
29 path: '/__webpack_hmr',
30}));
31
32app.listen(app.get('port'), function() {
33 console.log("Node app is running on port:" + app.get('port'))
34
35 if (process.env.npm_config_openBrowser) {
36 openBrowser(process.env.BROWSER_URL);
37 }
38})