Skip to content

Instantly share code, notes, and snippets.

@Naahuel
Naahuel / react-unused-files.sh
Last active July 17, 2018 17:21 — forked from dethi/unused-files.sh
Find files not used in the app bundle, i.e. unused source code
#!/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) \
let UserContext = React.createContext();
class App extends React.Component {
state = {
user: null,
setUser: user => {
this.setState({ user });
}
};