From 08209672fbd7f38b3eb4367d1c2773b6b100a1db Mon Sep 17 00:00:00 2001 From: nopast <490964186@qq.com> Date: Fri, 8 Mar 2019 16:56:21 +0800 Subject: [PATCH] webpack3 support --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5d17d6b..145510c 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,7 @@ const getRelativePath = (filePath) => { } const emitHandle = (compilation, callback) => { - compilation.entrypoints.forEach(({chunks}) => { + function chunksHandle(chunks) { const entryChunk = chunks.pop() entryChunk.files.forEach(filePath => { @@ -39,7 +39,17 @@ const emitHandle = (compilation, callback) => { assetFile.source = () => content }) }) - }) + } + + if(compilation.entrypoints instanceof Map) { + compilation.entrypoints.forEach(({chunks}) => chunksHandle(chunks)) + }else { + Object.keys(compilation.entrypoints).forEach(key => { + const { chunks } = compilation.entrypoints[key] + chunksHandle(chunks) + }) + } + callback() }