mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-29 21:17:34 +00:00
46 lines
953 B
TypeScript
46 lines
953 B
TypeScript
import Koa = require('koa');
|
|
import webpack = require('webpack');
|
|
import koaWebpack = require('koa-webpack');
|
|
|
|
const app = new Koa();
|
|
const config: webpack.Configuration = {};
|
|
const compiler = webpack(config);
|
|
|
|
// Using the middleware
|
|
|
|
const middleware = koaWebpack({
|
|
compiler,
|
|
config,
|
|
dev: {
|
|
lazy: true,
|
|
watchOptions: {
|
|
aggregateTimeout: 300,
|
|
poll: true,
|
|
},
|
|
publicPath: '/assets/',
|
|
index: 'index.html',
|
|
headers: {
|
|
'X-Custom-Header': 'yes'
|
|
},
|
|
stats: {
|
|
colors: true,
|
|
},
|
|
reporter: null,
|
|
serverSideRender: false
|
|
},
|
|
hot: {
|
|
log: console.log.bind(console),
|
|
path: '/__what',
|
|
heartbeat: 2000
|
|
}
|
|
});
|
|
|
|
app.use(middleware);
|
|
|
|
// Accessing the underlying middleware
|
|
|
|
middleware.dev.close();
|
|
middleware.dev.invalidate();
|
|
middleware.dev.waitUntilValid();
|
|
middleware.hot.publish(null);
|