i have a big project with a lot of images in the public folder of react app, is there a way to find all the unused images and clean them up ?
This is a common issue and this question led to me to search for answers. I stumbled upon this video which helped to partly resolve the issue.
The problem here is that, the plugin used in the video unused-files-webpack-plugin
does not support Webpack 5. An issue was raised to update the plugin to support Webpack 5 but the author of the package hasn't issued an update.
A similar package that can be used is the webpack-deadcode-plugin
. You can use the implementation from the video and substitute the unused-files-webpack-plugin
with the webpack-deadcode-plugin
making a few changes (such as to the patterns
property which you would have to change to something like: patterns: ['src/**/*.(png|jpg|jpeg)']
for your use case) to adapt the new plugin.
Edit: This answer assumes you are using webpack as your bundler.