Reputation: 1345
I'm upgrading a webpack plugin from v4 to v5. Part of my plugin used to read the compilation.assets
object to figure out the generated asset's absolute path to do some calculation.
But each asset in v5 now only contains the SizeOnlySource
object, which looks like this
{ _size: 840893 }
A subset of my plugin looks like this
compiler.hooks.afterEmit.tap('my-plugin', (compilation, callback) => {
Object.keys(compilation.assets).forEach((filename) => {
const asset = compilation.assets[filename];
const absolutePath = asset.existsAt;
// Do stuff ...
absolutePath
returns be undefined
in this case. My question is, what is the new way to access the absolute path of my file?
For reference I did look around but only information I could find was this issue that was closed immediately https://github.com/webpack/webpack/issues/12313
Upvotes: 0
Views: 316
Reputation: 1
Don't know if it could help you somehow but try accessing the compilation.assetsInfo instead:
new Map(compilation.assetsInfo).forEach(function(val, key) {
console.log('KEY: ' + key + ' -- VAL: ' + val.sourceFilename)
});
Im running through some issues like yours.
Upvotes: 0