You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
892 B

import { Express } from "express";
import * as paths from "paths";
import * as webpack from "webpack";
import * as webpackMiddleware from "webpack-dev-middleware";
import * as webpackHotMiddleware from "webpack-hot-middleware";
import logger from "@common/logger";
const log = logger.child({ source: "webpack" });
/* tslint:disable-next-line:no-var-requires */
const webpackConfig = require(paths.appWebpackConfig)("dev");
export default function serveApp(app: Express) {
const compiler = webpack(webpackConfig);
app.use(webpackMiddleware(compiler,
{
noInfo: true,
publicPath: webpackConfig.output.publicPath,
log: log.info.bind(log),
warn: log.warn.bind(log),
error: log.error.bind(log),
},
));
app.use(webpackHotMiddleware(compiler,
{
log: log.info.bind(log),
}));
}