Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Last active November 20, 2020 12:51
Show Gist options
  • Save xjamundx/0ea9838d937d4f3684ea79e85b11540b to your computer and use it in GitHub Desktop.
Save xjamundx/0ea9838d937d4f3684ea79e85b11540b 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 public/js/; # assumes all your files are here
find . -name "*.js" | 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