UNPKG

10.9 kBTypeScriptView Raw
1import * as webpack from 'webpack';
2import * as https from 'https';
3
4export = Config;
5
6declare namespace __Config {
7 class Chained<Parent> {
8 end(): Parent;
9 }
10
11 class TypedChainedMap<Parent, Value> extends Chained<Parent> {
12 clear(): this;
13 delete(key: string): this;
14 has(key: string): boolean;
15 get(key: string): Value;
16 set(key: string, value: Value): this;
17 merge(obj: { [key: string]: Value }): this;
18 entries(): { [key: string]: Value };
19 values(): Value[];
20 when(condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void): this;
21 }
22
23 class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
24
25 class TypedChainedSet<Parent, Value> extends Chained<Parent> {
26 add(value: Value): this;
27 prepend(value: Value): this;
28 clear(): this;
29 delete(key: string): this;
30 has(key: string): boolean;
31 merge(arr: Value[]): this;
32 values(): Value[];
33 when(condition: boolean, trueBrancher: (obj: this) => void, falseBrancher?: (obj: this) => void): this;
34 }
35
36 class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
37}
38
39declare class Config extends __Config.ChainedMap<void> {
40 devServer: Config.DevServer;
41 entryPoints: Config.TypedChainedMap<Config, Config.EntryPoint>;
42 module: Config.Module;
43 node: Config.ChainedMap<this>;
44 output: Config.Output;
45 optimization: Config.Optimization;
46 performance: Config.Performance;
47 plugins: Config.Plugins<this>;
48 resolve: Config.Resolve;
49 resolveLoader: Config.ResolveLoader;
50
51 amd(value: { [moduleName: string]: boolean }): this;
52 bail(value: boolean): this;
53 cache(value: boolean | any): this;
54 devtool(value: Config.DevTool): this;
55 context(value: string): this;
56 externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this;
57 loader(value: any): this;
58 name(value: string): this;
59 mode(value: 'none' | 'development' | 'production') : this;
60 parallelism(value: number) : this;
61 profile(value: boolean): this;
62 recordsPath(value: string): this;
63 recordsInputPath(value: string): this;
64 recordsOutputPath(value: string): this;
65 stats(value: webpack.Options.Stats): this;
66 target(value: string): this;
67 watch(value: boolean): this;
68 watchOptions(value: webpack.Options.WatchOptions): this;
69
70 entry(name: string): Config.EntryPoint;
71 plugin(name: string): Config.Plugin<this>;
72
73 toConfig(): webpack.Configuration;
74}
75
76declare namespace Config {
77 class Chained<Parent> extends __Config.Chained<Parent> {}
78 class TypedChainedMap<Parent, Value> extends __Config.TypedChainedMap<Parent, Value> {}
79 class ChainedMap<Parent> extends __Config.TypedChainedMap<Parent, any> {}
80 class TypedChainedSet<Parent, Value> extends __Config.TypedChainedSet<Parent, Value> {}
81 class ChainedSet<Parent> extends __Config.TypedChainedSet<Parent, any> {}
82
83 class Plugins<Parent> extends TypedChainedMap<Parent, Plugin<Parent>> {}
84
85 class Plugin<Parent> extends ChainedMap<Parent> implements Orderable {
86 init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this;
87 use(plugin: PluginClass, args?: any[]): this;
88 tap(f: (args: any[]) => any[]): this;
89
90 // Orderable
91 before(name: string): this;
92 after(name: string): this;
93 }
94
95 class Module extends ChainedMap<Config> {
96 rules: TypedChainedMap<this, Rule>;
97 rule(name: string): Rule;
98 noParse(noParse: RegExp | RegExp[] | ((contentPath: string) => boolean)): this;
99 }
100
101 class Output extends ChainedMap<Config> {
102 auxiliaryComment(value: string | { [comment:string]: string }): this;
103 chunkFilename(value: string): this;
104 chunkLoadTimeout(value: number): this;
105 crossOriginLoading(value: boolean | string): this;
106 filename(value: string): this;
107 library(value: string): this;
108 libraryExport(value: string | string[]): this;
109 libraryTarget(value: string): this;
110 devtoolFallbackModuleFilenameTemplate(value: any): this;
111 devtoolLineToLine(value: any): this;
112 devtoolModuleFilenameTemplate(value: any): this;
113 globalObject(value: string): this;
114 hashFunction(value: string): this;
115 hashDigest(value: string): this;
116 hashDigestLength(value: number): this;
117 hashSalt(value: any): this;
118 hotUpdateChunkFilename(value: string): this;
119 hotUpdateFunction(value: any): this;
120 hotUpdateMainFilename(value: string): this;
121 jsonpFunction(value: string): this;
122 path(value: string): this;
123 pathinfo(value: boolean): this;
124 publicPath(value: string): this;
125 sourceMapFilename(value: string): this;
126 sourcePrefix(value: string): this;
127 strictModuleExceptionHandling(value: boolean): this;
128 umdNamedDefine(value: boolean): this;
129 }
130
131 class DevServer extends ChainedMap<Config> {
132 allowedHosts: TypedChainedSet<this, string>;
133
134
135 bonjour(value: boolean): this;
136 clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this;
137 color(value: boolean): this;
138 compress(value: boolean): this;
139 contentBase(value: boolean | string | string[]): this;
140 disableHostCheck(value: boolean): this;
141 filename(value: string): this;
142 headers(value: { [header: string]: string }): this;
143 historyApiFallback(value: boolean | any): this;
144 host(value: string): this;
145 hot(value: boolean): this;
146 hotOnly(value: boolean): this;
147 https(value: boolean | https.ServerOptions): this;
148 inline(value: boolean): this;
149 info(value: boolean): this;
150 lazy(value: boolean): this;
151 noInfo(value: boolean): this;
152 open(value: boolean): this;
153 overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this;
154 pfx(value: string): this;
155 pfxPassphrase(value: string): this;
156 port(value: number): this;
157 progress(value: boolean): this;
158 proxy(value: any): this;
159 public(value: string): this;
160 publicPath(publicPath: string): this;
161 quiet(value: boolean): this;
162 setup(value: (expressApp: any) => void): this;
163 socket(value: string): this;
164 staticOptions(value: any): this;
165 stats(value: webpack.Options.Stats): this;
166 stdin(value: boolean): this;
167 useLocalIp(value: boolean): this;
168 watchContentBase(value: boolean): this;
169 watchOptions(value: any): this;
170 }
171
172 class Performance extends ChainedMap<Config> {
173 hints(value: boolean | 'error' | 'warning'): this;
174 maxEntrypointSize(value: number): this;
175 maxAssetSize(value: number): this;
176 assetFilter(value: (assetFilename: string) => boolean): this;
177 }
178
179 class EntryPoint extends TypedChainedSet<Config, string> {}
180
181 class Resolve extends ChainedMap<Config> {
182 alias: TypedChainedMap<this, string>;
183 aliasFields: TypedChainedSet<this, string>;
184 descriptionFiles: TypedChainedSet<this, string>;
185 extensions: TypedChainedSet<this, string>;
186 mainFields: TypedChainedSet<this, string>;
187 mainFiles: TypedChainedSet<this, string>;
188 modules: TypedChainedSet<this, string>;
189 plugins: TypedChainedMap<this, Plugin<this>>;
190
191 enforceExtension(value: boolean): this;
192 enforceModuleExtension(value: boolean): this;
193 unsafeCache(value: boolean | RegExp | RegExp[]): this;
194 symlinks(value: boolean): this;
195 cachePredicate(value: (data: { path: string, request: string }) => boolean): this;
196 cacheWithContext(value: boolean): this;
197
198 plugin(name: string): Plugin<this>;
199 }
200
201 class ResolveLoader extends Resolve {
202 moduleExtensions: ChainedSet<this>;
203 packageMains: ChainedSet<this>
204 }
205
206 class Rule extends ChainedMap<Module> {
207 oneOfs: TypedChainedMap<this, OneOf>;
208 uses: TypedChainedMap<this, Use>;
209 include: TypedChainedSet<this, webpack.Condition>;
210 exclude: TypedChainedSet<this, webpack.Condition>;
211
212 parser(value: { [optName: string]: any }): this;
213 test(value: webpack.Condition | webpack.Condition[]): this;
214 type(value: 'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/experimental'): this;
215 enforce(value: 'pre' | 'post'): this;
216
217 use(name: string): Use;
218 oneOf(name: string): OneOf;
219 pre(): this;
220 post(): this;
221 }
222
223 class Optimization extends ChainedMap<Config> {
224 concatenateModules(value: boolean): this;
225 flagIncludedChunks(value: boolean): this;
226 mergeDuplicateChunks(value: boolean): this;
227 minimize(value: boolean): this;
228 minimizer(name: string): Config.Plugin<this>;
229 namedChunks(value: boolean): this;
230 namedModules(value: boolean): this;
231 nodeEnv(value: boolean | string): this;
232 noEmitOnErrors(value: boolean): this;
233 occurrenceOrder(value: boolean): this;
234 portableRecords(value: boolean): this;
235 providedExports(value: boolean): this;
236 removeAvailableModules(value: boolean): this;
237 removeEmptyChunks(value: boolean): this;
238 runtimeChunk(value: boolean | "single" | "multiple" | RuntimeChunk): this;
239 sideEffects(value: boolean): this;
240 splitChunks(value: SplitChunksOptions): this;
241 usedExports(value: boolean): this;
242 }
243
244 interface RuntimeChunk {
245 name: string | RuntimeChunkFunction;
246 }
247
248 type RuntimeChunkFunction = (entryPoint: EntryPoint) => string;
249
250 interface SplitChunksOptions { [name: string]: any; }
251
252 interface LoaderOptions { [name: string]: any; }
253
254 class Use extends ChainedMap<Rule> implements Orderable {
255 loader(value: string): this;
256 options(value: LoaderOptions): this;
257
258 tap(f: (options: LoaderOptions) => LoaderOptions): this;
259
260 // Orderable
261 before(name: string): this;
262 after(name: string): this;
263 }
264
265 class OneOf extends ChainedMap<Rule> implements Orderable {
266 resourceQuery(value: webpack.Condition | webpack.Condition[]): this;
267 use(name: string): Use;
268
269 // Orderable
270 before(name: string): this;
271 after(name: string): this;
272 }
273
274 type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' |
275 'cheap-module-eval-source-map' | 'cheap-module-source-map' | 'eval-source-map' | 'source-map' |
276 'nosources-source-map' | 'hidden-source-map' | 'nosources-source-map' | '@eval' |
277 '@inline-source-map' | '@cheap-eval-source-map' | '@cheap-source-map' |
278 '@cheap-module-eval-source-map' | '@cheap-module-source-map' | '@eval-source-map' |
279 '@source-map' | '@nosources-source-map' | '@hidden-source-map' | '@nosources-source-map' |
280 '#eval' | '#inline-source-map' | '#cheap-eval-source-map' | '#cheap-source-map' |
281 '#cheap-module-eval-source-map' | '#cheap-module-source-map' | '#eval-source-map' |
282 '#source-map' | '#nosources-source-map' | '#hidden-source-map' | '#nosources-source-map' |
283 '#@eval' | '#@inline-source-map' | '#@cheap-eval-source-map' | '#@cheap-source-map' |
284 '#@cheap-module-eval-source-map' | '#@cheap-module-source-map' | '#@eval-source-map' |
285 '#@source-map' | '#@nosources-source-map' | '#@hidden-source-map' | '#@nosources-source-map' |
286 boolean;
287
288 interface PluginClass {
289 new (...opts: any[]): webpack.Plugin;
290 }
291
292 interface Orderable {
293 before(name: string): this;
294 after(name: string): this;
295 }
296}