-
-
Save Naahuel/a0b45b9b8367eeb6ef5adfde6b156a69 to your computer and use it in GitHub Desktop.
Find files not used in the app bundle, i.e. unused source code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Launch inside a react project after building the production build with webpack | |
# Require `jq`. | |
diff \ | |
<(find src -type f \( -name '*.js' -o -name '*.jsx' -o -name '*.scss' \) | sort) \ | |
<(cat dist/**/*.map | jq --raw-output '.sources | join("\n")' \ | |
| grep -v '\.\./' | grep -E '\.(js|jsx|scss)$' \ | |
| sed "s~^webpack:///\./~~" -r | sort | uniq) \ | |
| grep '< ' | sed "s#^< ##" | grep -v 'spec' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment