Skip to content

Commit ae86ee1

Browse files
committed
Fix “BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.” 🙈
1 parent 3892683 commit ae86ee1

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/build-file.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ export default function buildFile({ compiler, gitWorkTree, command, replacePatte
3030
if (!data) return path
3131
return path.replace(replacePattern, data)
3232
})
33-
})
3433

35-
compiler.hooks.emit.tap('GitRevisionWebpackPlugin', compilation => {
36-
compilation.assets[asset] = {
37-
source: function() {
38-
return data
39-
},
40-
size: function() {
41-
return data ? data.length : 0
42-
},
43-
buffer: function() {
44-
return Buffer.from(data)
45-
},
46-
map: function() {
47-
return {}
48-
},
49-
sourceAndMap: function() {
50-
return { source: data, map: {} }
51-
},
52-
updateHash: function() {},
53-
}
34+
compilation.hooks.processAssets.tap('GitRevisionWebpackPlugin', assets => {
35+
assets[asset] = {
36+
source: function() {
37+
return data
38+
},
39+
size: function() {
40+
return data ? data.length : 0
41+
},
42+
buffer: function() {
43+
return Buffer.from(data)
44+
},
45+
map: function() {
46+
return {}
47+
},
48+
sourceAndMap: function() {
49+
return { source: data, map: {} }
50+
},
51+
updateHash: function() {},
52+
}
53+
})
5454
})
5555
}

0 commit comments

Comments
 (0)