gpbl/webpack-cleanup-plugin

Incorrectly cleans up files from file-loader plugin with ./ in name

mobz opened this issue · 3 comments

mobz commented

If the file-loader is used, and there is a ./ in the name, emitted files will be cleaned up by this plugin

To see this behaviour,
Unzip attached project.

npm install && npm run build

You will see two files are emitted, but the svg is not in the dist directory.
If you remove the WebpackCleanupPlugin it will work as expected.
If you remove the ./ from the name part of the file-loader module it will work as expected

test-webpack-cleanup-plugin.zip

mobz commented

Playing around with this bit more, if I change WebpackCleanupPlugin.js:22 to

const assets = stats.toJson().assets.map(asset => path.join(asset.name) );

It resolves the issue, however I'm not sure that's the right thing to do

gpbl commented

Thanks @mobz for providing the zip to test this case. Your solution is right, the problem is when excluding files with a relative path in it. I've added the case in this test as it is a situation that getFiles should handle (not the plugin itself).

Going to release a fix soon!

gpbl commented

I've published the fix as v0.4.1. Feel free to write back if not working as expected.