Skip to content

Instantly share code, notes, and snippets.

@bpetetot
Created November 26, 2019 09:21
Show Gist options
  • Select an option

  • Save bpetetot/f9a435996ab3cca3c7017d77bbf1903c to your computer and use it in GitHub Desktop.

Select an option

Save bpetetot/f9a435996ab3cca3c7017d77bbf1903c to your computer and use it in GitHub Desktop.
Identify unused files with webpack
echo "Generating resolved modules list by webpack..."
npx webpack --display-modules --config webpack.config.js | awk '{print $2}' | grep ^\.\/ > files-webpack.txt
echo "Generating files list from src folder..."
find ./src -name "*.js" | grep -v eslint | grep -v stories | grep -v __ > ./files-src.txt
echo "Identify unused files..."
cat files-src.txt | xargs -I '{}' sh -c "grep -q '{}' files-webpack.txt || echo '{}'"
rm files-src.txt files-webpack.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment