Merge pull request #23480 from alan-agius4/feature/webpack-dev-server

feat: add missing `addDevServerEntrypoints` in `API`
This commit is contained in:
Daniel Rosenwasser
2018-02-16 15:57:31 -08:00
committed by GitHub
2 changed files with 28 additions and 3 deletions

View File

@@ -15,6 +15,10 @@ import * as spdy from 'spdy';
import * as httpProxyMiddleware from 'http-proxy-middleware';
declare namespace WebpackDevServer {
interface ListeningApp {
address(): { port?: number };
}
interface proxyConfigMap {
[url: string]: string | httpProxyMiddleware.Config;
}
@@ -76,6 +80,12 @@ declare class WebpackDevServer {
config: WebpackDevServer.Configuration
);
static addDevServerEntrypoints(
webpackOptions: webpack.Configuration | webpack.Configuration[],
config: WebpackDevServer.Configuration,
listeningApp?: WebpackDevServer.ListeningApp
): void;
listen(port: number, hostname: string, callback?: (error?: Error) => void): http.Server;
listen(port: number, callback?: (error?: Error) => void): http.Server;

View File

@@ -75,7 +75,7 @@ const config: WebpackDevServer.Configuration = {
// API example
server = new WebpackDevServer(compiler, config);
server.listen(8080, "localhost", () => {});
server.listen(8080, "localhost", () => { });
// HTTPS example
server = new WebpackDevServer(compiler, {
@@ -83,10 +83,25 @@ server = new WebpackDevServer(compiler, {
https: true
});
server.listen(8080, "localhost", () => {});
server.listen(8080, "localhost", () => { });
server.close();
// multiple compilers
WebpackDevServer.addDevServerEntrypoints(config, {
publicPath: "/assets/",
https: true
});
WebpackDevServer.addDevServerEntrypoints(
[config],
{
publicPath: "/assets/",
https: true
},
{
address: () => ({ port: 80 })
}
);
// multiple compilers
server = new WebpackDevServer(multipleCompiler, config);