From 2b9bfe8eaed8d298e699c3e0991dc7cd672ddb86 Mon Sep 17 00:00:00 2001 From: Michael Strobel Date: Wed, 12 Apr 2017 09:39:16 +0800 Subject: [PATCH] [webpack] Add resolve.plugins --- types/webpack/index.d.ts | 9 +++++++++ types/webpack/webpack-tests.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 7ebb99b10c..9e5d106b80 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -264,6 +264,11 @@ declare namespace webpack { */ cachePredicate?(data: { path: string, request: string }): boolean; + /** + * A list of additional resolve plugins which should be applied. + */ + plugins?: ResolvePlugin[]; + /** * Whether to resolve symlinks to their symlinked location. * @@ -594,6 +599,10 @@ declare namespace webpack { apply(compiler: Compiler): void; } + abstract class ResolvePlugin implements Tapable.Plugin { + apply(resolver: any /* EnhancedResolve.Resolver */): void; + } + abstract class Stats { /** Returns true if there were errors while compiling. */ hasErrors(): boolean; diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index e4afc33ccc..8572a11b41 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -577,7 +577,18 @@ configuration = { } }; +class TestResolvePlugin implements webpack.ResolvePlugin { + apply(resolver: any) { + resolver.plugin('before-existing-directory', (request: any, callback: any) => { + callback(); + }); + } +} + const resolve: webpack.Resolve = { + plugins: [ + new TestResolvePlugin() + ], symlinks: false, cachePredicate: 'boo' // why does this test _not_ fail!? };