Created
November 26, 2019 09:21
-
-
Save bpetetot/f9a435996ab3cca3c7017d77bbf1903c to your computer and use it in GitHub Desktop.
Identify unused files with webpack
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
| 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