forked from shellscape/webpack-plugin-serve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
90 lines (81 loc) · 2.31 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { Url } from 'url';
import {
Config as HttpProxyMiddlewareConfig,
Proxy
} from 'http-proxy-middleware';
import * as Koa from 'koa';
import {
ServerOptions as Http2ServerOptions,
SecureServerOptions as Http2SecureServerOptions
} from 'http2';
import { ServerOptions as HttpsServerOptions} from 'https';
import { ZlibOptions } from 'zlib';
declare module 'webpack-plugin-serve' {
interface CompressOptions extends ZlibOptions {
filter?: (content_type: string) => boolean;
threshold?: number;
}
interface KoaStaticOptions {
maxage?: number;
hidden?: boolean;
index?: string;
defer?: boolean;
gzip?: boolean;
br?: boolean;
setHeaders?: (res, path, stats) => any;
extensions?: Array<string> | boolean;
}
type RewriteTo = (context: Context) => string;
interface Context {
match: RegExpMatchArray;
parsedUrl: Url;
}
interface Rewrite {
from: RegExp;
to: string | RegExp | RewriteTo;
}
interface HistoryApiFallbackOptions {
disableDotRule?: true;
htmlAcceptHeaders?: string[];
index?: string;
logger?: typeof console.log;
rewrites?: Rewrite[];
verbose?: boolean;
}
interface Builtins {
proxy: (args: HttpProxyMiddlewareConfig) => Proxy;
compress: (opts: CompressOptions) => void;
static: (opts: KoaStaticOptions) => void;
historyFallback: (opts: HistoryApiFallbackOptions) => void;
websocket: () => void;
four0four: (fn?: (ctx: Koa.Context) => void) => void;
}
export interface WebpackPluginServeOptions {
client?: {
address: string;
};
compress?: boolean;
historyFallback?: boolean | HistoryApiFallbackOptions;
hmr?: boolean;
host?: string | (() => Promise<string>) | (() => string);
http2?: boolean | Http2ServerOptions | Http2SecureServerOptions;
https?: HttpsServerOptions;
liveReload?: boolean;
log?: {
level: string;
timestamp?: boolean;
};
middleware?: (app: Koa, builtins: Builtins) => void;
open?: boolean | {
wait?: boolean;
app?: string | ReadonlyArray<string>;
};
port?: number | (() => Promise<number>) | (() => number);
progress?: boolean | 'minimal';
static?: string | Array<string>;
status?: boolean;
}
export class WebpackPluginServe {
constructor(opts?: WebpackPluginServeOptions);
}
}