Skip to content

Instantly share code, notes, and snippets.

View tarekrached's full-sized avatar

Tarek Rached tarekrached

View GitHub Profile
@dethi
dethi / unused-files.sh
Last active April 25, 2022 05:34
create-react-app: find files not used in the app bundle, i.e. unused source code
#!/bin/bash
# Launch inside a create-react-app project after building the production build.
# Require `jq`.
diff \
<(find src -type f \( -name '*.js' -o -name '*.jsx' -o -name '*.css' \) | sort) \
<(cat build/**/*.map | jq --raw-output '.sources | join("\n")' \
| grep -v '\.\./' | grep -E '\.(js|jsx|css)$' \
| sed "s#^#src/#" | sort | uniq) \