Skip to content

Commit 121b481

Browse files
authored
Make removeAssets more flexible (#40)
1 parent d9b5ed7 commit 121b481

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ module.exports = class SpikeUtils {
121121
})
122122

123123
// first we remove the files from webpack's `assets`
124-
const filesDotJs = files.map((f) => `${f}.js`)
125-
for (const a in compilation.assets) {
126-
if (filesDotJs.indexOf(a) > -1) { delete compilation.assets[a] }
124+
const chunksByName = compilation.records.chunks.byName
125+
const chunkNames = Object.keys(compilation.assets)
126+
for (let k in chunksByName) {
127+
// if the chunk name is in our spike-processed files, we remove
128+
// that chunk from the assets to be written
129+
if (files.indexOf(k) > -1) {
130+
delete compilation.assets[chunkNames[chunksByName[k]]]
131+
}
127132
}
128133

129134
// Now we remove any chunks that are not further processed.

0 commit comments

Comments
 (0)