From 337913168d9eac61980478f84f835ba322ff1aae Mon Sep 17 00:00:00 2001 From: Manu Schiller Date: Mon, 21 May 2018 14:43:39 +0200 Subject: [PATCH] Add webpack 4 compatibility --- src/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index fdcb9f5..a477ef8 100755 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,6 @@ export default class IconfontPlugin { } this.options = Object.assign({}, options); - this.fileDependencies = []; this.hashes = {}; this.compile = this.compile.bind(this); @@ -85,8 +84,16 @@ export default class IconfontPlugin { globPatterns.forEach(globPattern => { const context = globParent(globPattern); - if (compilation.contextDependencies.indexOf(context) === -1) { - compilation.contextDependencies.push(context); + const contextDependencies = compilation.contextDependencies; + + if (contextDependencies instanceof Set) { + if (!contextDependencies.has(context)) { + contextDependencies.add(context); + } + } else if (Array.isArray(contextDependencies)) { + if (contextDependencies.indexOf(context) === -1) { + contextDependencies.push(context); + } } });