Package Exports
- cleanup-unused-images
- cleanup-unused-images/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cleanup-unused-images) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cleanup Unused Images
A tool to find and remove unused images in your project.
🚀 Installation
npm install -g cleanup-unused-images
📖 Usage
1. Thêm cấu hình vào package.json
{
"scripts": {
"cleanup-images": "cleanup-unused-images"
},
"cleanupImages": {
"directories": ["src/assets", "public/images"],
"extensions": ["jpg", "png", "svg"],
"exclude": ["node_modules", "dist"],
"ignorePatterns": ["**/background-*.png"],
"reportOutput": "./cleanup-report.json"
}
}
⚙️ Options
Option | Description | Default |
---|---|---|
--dir |
Directory containing images | . |
--ext |
Image file extensions | jpg,jpeg,png,gif,svg |
--exclude |
Directories to exclude | - |
--dryrun |
Test run without deleting | false |
2. Run the command
# Scan entire project
npm run cleanup-images
# Run with options
npx cleanup-unused-images --dir=src/assets/images --ext=jpg,png,svg
🎯 Examples
# Quét thư mục cụ thể
npx cleanup-unused-images --dir=src/assets
# Chỉ quét file PNG và SVG
npx cleanup-unused-images --ext=png,svg
# Loại trừ thư mục node_modules và dist
npx cleanup-unused-images --exclude=node_modules,dist
# Chạy thử nghiệm
npx cleanup-unused-images --dryrun
🖥️ UI Example
// Kết quả sẽ hiển thị bằng tiếng Hàn
{
"검색된 이미지": "100개",
"미사용 이미지": "15개",
"절약 가능한 용량": "25MB"
}
🎯 Ví dụ nâng cao
# Quét nhiều thư mục
npx cleanup-unused-images --dir=src/assets,public/images
# Tạo báo cáo JSON
npx cleanup-unused-images --report=cleanup-report.json
# Bỏ qua các file theo mẫu
npx cleanup-unused-images --ignore="**/temp-*.png,**/draft-*.jpg"
# Chạy tự động định kỳ
npx cleanup-unused-images --auto-schedule="0 0 * * *"
⚠️ Important Notes
- Backup your project before running
- Test with
--dryrun
option first - Ensure image paths in code are correct
- The tool scans source files for image references
🔍 Results
The tool will display:
- Number of scanned images
- List of unused images
- Potential space that can be freed
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
📋 Requirements
- Node.js 14.x or higher
- npm or yarn package manager
🐛 Troubleshooting
If you encounter any issues:
- Ensure all paths are correct
- Check file permissions
- Verify image extensions are supported
- Run with
--dryrun
to debug
📄 License
MIT
📞 Support
For support:
- Create an issue on GitHub
- Check existing issues for solutions
- Review documentation
Made with ❤️ for cleaner projects