|
| 1 | +import * as webpack from 'webpack'; |
| 2 | +import * as https from 'https'; |
| 3 | + |
| 4 | +export = Config; |
| 5 | + |
| 6 | +declare 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 | + |
| 39 | +declare 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 | + mode(value: 'development' | 'production') : this; |
| 59 | + parallelism(value: number) : this; |
| 60 | + profile(value: boolean): this; |
| 61 | + recordsPath(value: string): this; |
| 62 | + recordsInputPath(value: string): this; |
| 63 | + recordsOutputPath(value: string): this; |
| 64 | + stats(value: webpack.Options.Stats): this; |
| 65 | + target(value: string): this; |
| 66 | + watch(value: boolean): this; |
| 67 | + watchOptions(value: webpack.Options.WatchOptions): this; |
| 68 | + |
| 69 | + entry(name: string): Config.EntryPoint; |
| 70 | + plugin(name: string): Config.Plugin<this>; |
| 71 | + |
| 72 | + toConfig(): webpack.Configuration; |
| 73 | +} |
| 74 | + |
| 75 | +declare namespace Config { |
| 76 | + class Chained<Parent> extends __Config.Chained<Parent> {} |
| 77 | + class TypedChainedMap<Parent, Value> extends __Config.TypedChainedMap<Parent, Value> {} |
| 78 | + class ChainedMap<Parent> extends __Config.TypedChainedMap<Parent, any> {} |
| 79 | + class TypedChainedSet<Parent, Value> extends __Config.TypedChainedSet<Parent, Value> {} |
| 80 | + class ChainedSet<Parent> extends __Config.TypedChainedSet<Parent, any> {} |
| 81 | + |
| 82 | + class Plugins<Parent> extends TypedChainedMap<Parent, Plugin<Parent>> {} |
| 83 | + |
| 84 | + class Plugin<Parent> extends ChainedMap<Parent> implements Orderable { |
| 85 | + init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this; |
| 86 | + use(plugin: PluginClass, args?: any[]): this; |
| 87 | + tap(f: (args: any[]) => any[]): this; |
| 88 | + |
| 89 | + // Orderable |
| 90 | + before(name: string): this; |
| 91 | + after(name: string): this; |
| 92 | + } |
| 93 | + |
| 94 | + class Module extends ChainedMap<Config> { |
| 95 | + rules: TypedChainedMap<this, Rule>; |
| 96 | + rule(name: string): Rule; |
| 97 | + noParse(noParse: RegExp | RegExp[] | ((contentPath: string) => boolean)): this; |
| 98 | + } |
| 99 | + |
| 100 | + class Output extends ChainedMap<Config> { |
| 101 | + auxiliaryComment(value: string | { [comment:string]: string }): this; |
| 102 | + chunkFilename(value: string): this; |
| 103 | + chunkLoadTimeout(value: number): this; |
| 104 | + crossOriginLoading(value: boolean | string): this; |
| 105 | + filename(value: string): this; |
| 106 | + library(value: string): this; |
| 107 | + libraryExport(value: string | string[]): this; |
| 108 | + libraryTarget(value: string): this; |
| 109 | + devtoolFallbackModuleFilenameTemplate(value: any): this; |
| 110 | + devtoolLineToLine(value: any): this; |
| 111 | + devtoolModuleFilenameTemplate(value: any): this; |
| 112 | + hashFunction(value: string): this; |
| 113 | + hashDigest(value: string): this; |
| 114 | + hashDigestLength(value: number): this; |
| 115 | + hashSalt(value: any): this; |
| 116 | + hotUpdateChunkFilename(value: string): this; |
| 117 | + hotUpdateFunction(value: any): this; |
| 118 | + hotUpdateMainFilename(value: string): this; |
| 119 | + jsonpFunction(value: string): this; |
| 120 | + path(value: string): this; |
| 121 | + pathinfo(value: boolean): this; |
| 122 | + publicPath(value: string): this; |
| 123 | + sourceMapFilename(value: string): this; |
| 124 | + sourcePrefix(value: string): this; |
| 125 | + strictModuleExceptionHandling(value: boolean): this; |
| 126 | + umdNamedDefine(value: boolean): this; |
| 127 | + } |
| 128 | + |
| 129 | + class DevServer extends ChainedMap<Config> { |
| 130 | + allowedHosts: TypedChainedSet<this, string>; |
| 131 | + |
| 132 | + |
| 133 | + bonjour(value: boolean): this; |
| 134 | + clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this; |
| 135 | + color(value: boolean): this; |
| 136 | + compress(value: boolean): this; |
| 137 | + contentBase(value: boolean | string | string[]): this; |
| 138 | + disableHostCheck(value: boolean): this; |
| 139 | + filename(value: string): this; |
| 140 | + headers(value: { [header: string]: string }): this; |
| 141 | + historyApiFallback(value: boolean | any): this; |
| 142 | + host(value: string): this; |
| 143 | + hot(value: boolean): this; |
| 144 | + hotOnly(value: boolean): this; |
| 145 | + https(value: boolean | https.ServerOptions): this; |
| 146 | + inline(value: boolean): this; |
| 147 | + info(value: boolean): this; |
| 148 | + lazy(value: boolean): this; |
| 149 | + noInfo(value: boolean): this; |
| 150 | + open(value: boolean): this; |
| 151 | + overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this; |
| 152 | + pfx(value: string): this; |
| 153 | + pfxPassphrase(value: string): this; |
| 154 | + port(value: number): this; |
| 155 | + progress(value: boolean): this; |
| 156 | + proxy(value: any): this; |
| 157 | + public(value: string): this; |
| 158 | + publicPath(publicPath: string): this; |
| 159 | + quiet(value: boolean): this; |
| 160 | + setup(value: (expressApp: any) => void): this; |
| 161 | + socket(value: string): this; |
| 162 | + staticOptions(value: any): this; |
| 163 | + stats(value: webpack.Options.Stats): this; |
| 164 | + stdin(value: boolean): this; |
| 165 | + useLocalIp(value: boolean): this; |
| 166 | + watchContentBase(value: boolean): this; |
| 167 | + watchOptions(value: any): this; |
| 168 | + } |
| 169 | + |
| 170 | + class Performance extends ChainedMap<Config> { |
| 171 | + hints(value: boolean | 'error' | 'warning'): this; |
| 172 | + maxEntrypointSize(value: number): this; |
| 173 | + maxAssetSize(value: number): this; |
| 174 | + assetFilter(value: (assetFilename: string) => boolean): this; |
| 175 | + } |
| 176 | + |
| 177 | + class EntryPoint extends TypedChainedSet<Config, string> {} |
| 178 | + |
| 179 | + class Resolve extends ChainedMap<Config> { |
| 180 | + alias: TypedChainedMap<this, string>; |
| 181 | + aliasFields: TypedChainedSet<this, string>; |
| 182 | + descriptionFiles: TypedChainedSet<this, string>; |
| 183 | + extensions: TypedChainedSet<this, string>; |
| 184 | + mainFields: TypedChainedSet<this, string>; |
| 185 | + mainFiles: TypedChainedSet<this, string>; |
| 186 | + modules: TypedChainedSet<this, string>; |
| 187 | + plugins: TypedChainedMap<this, Plugin<this>>; |
| 188 | + |
| 189 | + enforceExtension(value: boolean): this; |
| 190 | + enforceModuleExtension(value: boolean): this; |
| 191 | + unsafeCache(value: boolean | RegExp | RegExp[]): this; |
| 192 | + symlinks(value: boolean): this; |
| 193 | + cachePredicate(value: (data: { path: string, request: string }) => boolean): this; |
| 194 | + cacheWithContext(value: boolean): this; |
| 195 | + |
| 196 | + plugin(name: string): Plugin<this>; |
| 197 | + } |
| 198 | + |
| 199 | + class ResolveLoader extends ChainedMap<Config> { |
| 200 | + extensions: TypedChainedSet<this, string>; |
| 201 | + modules: TypedChainedSet<this, string>; |
| 202 | + moduleExtensions: TypedChainedSet<this, string>; |
| 203 | + packageMains: TypedChainedSet<this, string>; |
| 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 | + enforce(value: 'pre' | 'post'): this; |
| 215 | + |
| 216 | + use(name: string): Use; |
| 217 | + oneOf(name: string): OneOf; |
| 218 | + pre(): this; |
| 219 | + post(): this; |
| 220 | + } |
| 221 | + |
| 222 | + class Optimization extends ChainedMap<Config> { |
| 223 | + concatenateModules(value: boolean): this; |
| 224 | + flagIncludedChunks(value: boolean): this; |
| 225 | + mergeDuplicateChunks(value: boolean): this; |
| 226 | + minimize(value: boolean): this; |
| 227 | + minimizer(name: string): Config.Plugin<this>; |
| 228 | + namedChunks(value: boolean): this; |
| 229 | + namedModules(value: boolean): this; |
| 230 | + nodeEnv(value: boolean | string): this; |
| 231 | + noEmitOnErrors(value: boolean): this; |
| 232 | + occurrenceOrder(value: boolean): this; |
| 233 | + portableRecords(value: boolean): this; |
| 234 | + providedExports(value: boolean): this; |
| 235 | + removeAvailableModules(value: boolean): this; |
| 236 | + removeEmptyChunks(value: boolean): this; |
| 237 | + runtimeChunk(value: boolean | "single" | "multiple" | RuntimeChunk): this; |
| 238 | + sideEffects(value: boolean): this; |
| 239 | + splitChunks(value: SplitChunksOptions): this; |
| 240 | + usedExports(value: boolean): this; |
| 241 | + } |
| 242 | + |
| 243 | + interface RuntimeChunk { |
| 244 | + name: string | RuntimeChunkFunction; |
| 245 | + } |
| 246 | + |
| 247 | + type RuntimeChunkFunction = (entryPoint: EntryPoint) => string; |
| 248 | + |
| 249 | + interface SplitChunksOptions { [name: string]: any; } |
| 250 | + |
| 251 | + interface LoaderOptions { [name: string]: any; } |
| 252 | + |
| 253 | + class Use extends ChainedMap<Rule> implements Orderable { |
| 254 | + loader(value: string): this; |
| 255 | + options(value: LoaderOptions): this; |
| 256 | + |
| 257 | + tap(f: (options: LoaderOptions) => LoaderOptions): this; |
| 258 | + |
| 259 | + // Orderable |
| 260 | + before(name: string): this; |
| 261 | + after(name: string): this; |
| 262 | + } |
| 263 | + |
| 264 | + class OneOf extends ChainedMap<Rule> implements Orderable { |
| 265 | + resourceQuery(value: webpack.Condition | webpack.Condition[]): this; |
| 266 | + use(name: string): Use; |
| 267 | + |
| 268 | + // Orderable |
| 269 | + before(name: string): this; |
| 270 | + after(name: string): this; |
| 271 | + } |
| 272 | + |
| 273 | + type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' | |
| 274 | + 'cheap-module-eval-source-map' | 'cheap-module-source-map' | 'eval-source-map' | 'source-map' | |
| 275 | + 'nosources-source-map' | 'hidden-source-map' | 'nosources-source-map' | '@eval' | |
| 276 | + '@inline-source-map' | '@cheap-eval-source-map' | '@cheap-source-map' | |
| 277 | + '@cheap-module-eval-source-map' | '@cheap-module-source-map' | '@eval-source-map' | |
| 278 | + '@source-map' | '@nosources-source-map' | '@hidden-source-map' | '@nosources-source-map' | |
| 279 | + '#eval' | '#inline-source-map' | '#cheap-eval-source-map' | '#cheap-source-map' | |
| 280 | + '#cheap-module-eval-source-map' | '#cheap-module-source-map' | '#eval-source-map' | |
| 281 | + '#source-map' | '#nosources-source-map' | '#hidden-source-map' | '#nosources-source-map' | |
| 282 | + '#@eval' | '#@inline-source-map' | '#@cheap-eval-source-map' | '#@cheap-source-map' | |
| 283 | + '#@cheap-module-eval-source-map' | '#@cheap-module-source-map' | '#@eval-source-map' | |
| 284 | + '#@source-map' | '#@nosources-source-map' | '#@hidden-source-map' | '#@nosources-source-map' | |
| 285 | + boolean; |
| 286 | + |
| 287 | + interface PluginClass { |
| 288 | + new (...opts: any[]): webpack.Plugin; |
| 289 | + } |
| 290 | + |
| 291 | + interface Orderable { |
| 292 | + before(name: string): this; |
| 293 | + after(name: string): this; |
| 294 | + } |
| 295 | +} |
0 commit comments