1 | const path = require('path');
|
2 | const webpack = require('webpack');
|
3 | const webpackDevMiddleware = require("webpack-dev-middleware");
|
4 | const webpackHotMiddleware = require("webpack-hot-middleware");
|
5 | const webpackConfig = require('./webpack.config');
|
6 | const express = require("express");
|
7 |
|
8 | const app = express();
|
9 | const compiler = webpack(webpackConfig);
|
10 |
|
11 | app.set('port', 3000);
|
12 |
|
13 | app.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 | }));
|
28 | app.use(webpackHotMiddleware(compiler, {
|
29 | path: '/__webpack_hmr',
|
30 | }));
|
31 |
|
32 | app.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 | })
|