Quickly identify unused files in your project to help slim down your codebase.
ä¸ć–‡ć–‡ćˇŁďĽšhttps://github.com/laoer536/minipp/blob/main/README.zh.md
Rust version: https://github.com/laoer536/minipp-rs
Warning
src directory. Requires Node.js version >= 20 to run.
- TypeScript:
.ts,.tsx - Style files:
.css,.less,.scss - Media files:
.png,.jpg,.jpeg,.gif,.svg,.mp3,.mp4,.wav,.woff,.woff2,.ttf,.eot,.json
-
TypeScript/TSX Files:
- ES Module
importstatements - Static import paths
- Relative path imports
- TypeScript path aliases (e.g.,
@/*) // Supported by default - Dynamic
import()statements
- ES Module
-
Style Files:
@importstatements- Resource references in
url()functions - Relative path references
- Path alias references
Create a minipp.config.ts file in the project root:
import { defineMinippConfig } from 'minipp'
export default defineMinippConfig({
ignoreFiles: ['src/index.ts', 'src/core/cli/index.ts'],
ignoreDependencies: ['@types/node'],
})Glob patterns are also supported:
export default defineMinippConfig({
needDel: false,
ignoreFiles: ['src/index.ts', 'src/core/**'],
ignoreDependencies: ['@types*'],
})Supports Deleting Unused Files and Removing Unused Dependencies from package.json (Backups are saved in the minipp-delete-files folder)
-
High Performance:
- Fast analysis even in large projects
- Optimized file scanning algorithm
- Efficient memory usage
-
Comprehensive Analysis:
- Supports multiple file types (TypeScript, TSX, CSS, media files, etc.)
- Handles various import methods and path aliases
- Detailed JSON report output
-
Developer-Friendly:
- Simple command-line interface
- Clear and detailed output format
- Easy integration into existing workflows
-
Project Optimization:
- Identifies and removes unused files
- Reduces project size
- Improves codebase maintainability
-
Dynamic Imports:
- Template string paths are not supported
- Conditional imports are not supported
-
CommonJS Modules:
require()syntax is not supported- Webpack-specific syntax like
require.context()is not supported module.exportsandexportsare not supported
-
Path Resolution:
- Runtime dynamically constructed paths are not supported
- Custom path aliases (other than
@/) are not supported (default@/is resolved tosrc/) - Complex path mapping rules (e.g., multiple wildcards) are not supported
-
Special Syntax:
- CSS-in-JS style references are not supported
- Vue single-file component dependency resolution is not supported
- Accuracy:
- For files loaded automatically at runtime (without explicit imports in code), the tool cannot determine if they are used (currently classified as unused). Users must manually verify such files before deletion.
npm install minipp -Dyarn add minipp -Dpnpm add minipp -Dimport { defineMinippConfig } from 'minipp'
export default defineMinippConfig({
ignoreFiles: ['src/index.ts', 'src/core/cli/index.ts'],
ignoreDependencies: ['@types/node'],
})Glob patterns are also supported:
export default defineMinippConfig({
needDel: false,
ignoreFiles: ['src/index.ts', 'src/core/**'],
ignoreDependencies: ['@types*'],
})You can also install it globally:
npm install minipp -gDon't forget to create minipp.config.ts in the target project's root directory.
minippminipp /path/to/your/project- Path Aliases:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"] // Supported by default
}
}
}- Usage Examples:
// Relative path imports
import { Button } from './components/Button';
import { Button } from '../../components/Button';
import { Button } from '../components/Button';
// Path alias imports
import { utils } from '@/utils'; // Resolved as "src/utils"
import { config } from '@config/settings'; // Treated as an external dependency, not a local resource
// BaseUrl imports
import { types } from 'types';@/utils->src/utils./utils-> Resolved relative to the current file's directory../utils-> Resolved relative to the parent directory of the current file (supports'../../utils', '..', etc.)
- Import information in code files
- Import information in CSS/LESS/SCSS files
- Unused file information
- Unused dependencies in code
- Used dependencies in code
Example:
{
"jsLikePathImports": [
"src/core/processors/js-like.ts",
"src/core/processors/style-like.ts",
"src/core/common/index.ts",
"src/core/cli/index.ts",
"src/core/visitor/index.ts"
],
"jsLikeDependenceImports": [
"fs",
"path",
"glob",
"yocto-spinner",
"util",
"@swc/core"
],
"styleLikeImports": [],
"unusedFile": [
"src/index.ts"
],
"codeUnusedDependencies": [
"@swc/cli",
"@types/node",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
"changelogen",
"eslint",
"prettier",
"tsconfig-paths",
"tsx",
"typescript",
"unbuild"
]
}- It is recommended to run the tool in the project root directory.
- Support for JavaScript and JSX parsing
- Support for Vue single-file components