Skip to content

Instantly share code, notes, and snippets.

@paulcurley
Forked from xjamundx/webpack-unused-files.sh
Created December 18, 2018 14:30
Show Gist options
  • Save paulcurley/aaa79fe84559ab63fa5402007ff58d4e to your computer and use it in GitHub Desktop.
Save paulcurley/aaa79fe84559ab63fa5402007ff58d4e 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