Overview
repo2pdf allows you to exclude specific files, directories, and file types from your generated PDF using arepo2pdf.ignore configuration file. This is essential for keeping your PDFs focused and avoiding unnecessary content.
Quick Start
Create arepo2pdf.ignore file in your repository root:
repo2pdf.ignore
Configuration Format
Therepo2pdf.ignore file is a JSON file with two arrays:
Array of file names and directory names to exclude
Array of file extensions to exclude (include the dot)
How It Works
The ignore system works in multiple layers:1. Universal Excludes (Always Applied)
repo2pdf has built-in exclusions that are always applied: FromuniversalExcludes.ts:1-31:
These exclusions cannot be overridden. They are applied to every repo2pdf run.
2. Custom Ignores (From repo2pdf.ignore)
Your custom ignores are added to the universal excludes: Fromclone.ts:182-196:
3. Loading the Configuration
Therepo2pdf.ignore file is loaded from the repository root:
From loadIgnoreConfig.ts:9-24:
Ignore Patterns by Type
Ignoring Directories
Ignoring Directories
To ignore an entire directory, add its name to The directory name is matched against
ignoredFiles:path.basename(filePath), so:node_modulesmatches./node_modules/and./packages/app/node_modules/distmatches./dist/and./packages/core/dist/
Ignoring Specific Files
Ignoring Specific Files
To ignore specific files by name:Like directories, file name matching is exact and applies anywhere in the tree.
Ignoring File Extensions
Ignoring File Extensions
To ignore all files with specific extensions:Extensions are matched using
Always include the dot in the extension:
".map", not "map".path.extname(), so:".map"matchesbundle.js.map,app.css.map, etc.".log"matchesdebug.log,error.log, etc.
Combining Multiple Patterns
Combining Multiple Patterns
You can combine files, directories, and extensions:All patterns are applied together - a file is excluded if it matches any pattern.
Common Use Cases
Node.js Projects
TypeScript Projects
Python Projects
Next.js Projects
Debugging Ignore Patterns
To verify your ignore patterns are working:-
Check the file count: After running repo2pdf, you’ll see:
-
Compare with git: Use
git ls-filesto see what Git tracks - Review the PDF: Open the generated PDF and verify excluded files aren’t present
File Path Matching
Matching is done on base name only:- You cannot use glob patterns like
src/**/*.test.js - You cannot use full paths like
/src/test/fixtures - You can match any file/directory with that exact name
- You can match any file with that exact extension
Error Handling
File Not Found
If
repo2pdf.ignore doesn’t exist:- No error is thrown
- Only universal excludes are applied
- Processing continues normally
Invalid JSON
If the file exists but contains invalid JSON:
- An error is thrown
- repo2pdf stops execution
- You must fix the JSON syntax
Best Practices
Start Minimal
Begin with a small ignore list and expand as needed
Use Comments
JSON doesn’t support comments, but you can document in your README
Version Control
Commit
repo2pdf.ignore so all team members use the same settingsTest Changes
After updating, run repo2pdf and verify the file count changes
Example from repo2pdf Source
The repo2pdf repository itself uses this ignore file:repo2pdf.ignore
- TypeScript configuration
- Built JavaScript output
- Dependencies
- Raw data files
Interface Definition
The TypeScript interface ensures type safety: FromloadIgnoreConfig.ts:4-7: