DefinitelyTyped/types/webpack-serve/webpack-serve-tests.ts
ZSkycat ba3048433e [webpack-serve] update to version 2.0.0 (#27173)
* [webpack-serve] create a new subfolder with the v1

* [webpack-serve] update to version 2.0.0

* [webpack-serve] add the correct path mapping for the v1
2018-07-12 10:05:31 -07:00

50 lines
1.0 KiB
TypeScript

import webpack = require('webpack');
import serve = require('webpack-serve');
const webpackConfig: webpack.Configuration = {
entry: { index: './index.js' },
};
const webpackCompiler = webpack(webpackConfig);
const serveConfig: serve.Options = {
add: (app, middleware, options) => {
middleware.content();
middleware.webpack();
},
compiler: webpackCompiler,
config: webpackConfig,
content: './webroot',
clipboard: true,
devMiddleware: {
logLevel: 'warn',
publicPath: '/',
},
host: 'localhost',
hotClient: {
logLevel: 'warn',
allEntries: true,
},
http2: true,
https: {},
logLevel: 'info',
logTime: false,
on: {
'build-finished': args => {
console.log(args.stats.toString());
},
},
open: {
path: '/index.html',
},
port: 65080,
};
const promise = serve({}, serveConfig);
promise.then(result => {
result.on('compiler-error', args => {
console.log(args.stats);
});
});