Skip to content

Instantly share code, notes, and snippets.

@Billy-
Forked from xjamundx/webpack-unused-files.sh
Created January 22, 2019 14:39
Show Gist options
  • Save Billy-/114b6d8e4d5662f7d3c8014586da155b to your computer and use it in GitHub Desktop.
Save Billy-/114b6d8e4d5662f7d3c8014586da155b to your computer and use it in GitHub Desktop.
Quickly identify files unused by webpack
# ----------------------------------- #
webpack --display-modules | awk '{print $2}' | grep ^\.\/ > files-processed.txt;
cd src; # assumes all your files are here
find . -name *.js?(x) | grep -v eslint | grep -v __ > ../../files-all.txt; # excludes __tests__ and .eslintrc files
cd ..;
cat files-all.txt | xargs -I '{}' sh -c "grep -q '{}' files-processed.txt || echo '{}'";
rm files-processed.txt files-all.txt;
# ----------------------------------- #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment