Skip to content

Commit

Permalink
webpack3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
BugKun committed Mar 8, 2019
1 parent b463530 commit 0820967
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 0820967

Please sign in to comment.