diff --git a/src/interfaces.ts b/src/interfaces.ts index b2ea77d..15bebaa 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -10,6 +10,10 @@ type Compiler = webpack.Compiler & { } type Options = UserOptions & { + /** + * Reuse existing utils if exists + */ + utils?: WindiPluginUtils // add custom webpack options here } diff --git a/src/plugin.ts b/src/plugin.ts index d4232e6..16c49af 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -206,11 +206,14 @@ class WindiCSSWebpackPlugin { // Make windy service available to the loader const initWindyCSSService = async() => { if (!compiler.$windyCSSService) { + const utils = this.options.utils ?? createUtils(this.options, { + root, + name: NAME, + }) + compiler.$windyCSSService = Object.assign( - createUtils(this.options, { - root, - name: NAME, - }), { + utils, + { root, dirty: new Set(), },