Auto-Discovery
jstatico automatically discovers processors in the _processors/ directory.
Directory Structure
src/
├── _processors/
│ ├── preprocessors/
│ │ └── myPreprocessor.ts
│ ├── postprocessors/
│ │ └── myPostprocessor.ts
│ └── writers/
│ └── myWriter.ts
└── ...How It Works
- jstatico scans
_processors/subdirectories - Loads
.tsand.jsfiles alphabetically - Expects
processororwriterexport - Registers discovered processors
Example
Create _processors/preprocessors/uppercase.ts:
import type { Preprocessor, ProcessResult } from 'jstatico';
export const processor: Preprocessor = {
name: 'uppercase',
match: /\.upper$/,
process: function(): ProcessResult {
return {
extension: '.txt',
content: this.getContent().toUpperCase()
};
}
};Now any .upper file will be converted to uppercase .txt.
Precedence
Processors are applied in this order:
- Programmatic (via Builder API)
- Auto-discovered (from
_processors/) - Built-in
Later processors can override earlier ones with the same match pattern.
Disabling Auto-Discovery
Use the Builder API to skip auto-discovery:
import { jstatico } from 'jstatico/builder';
await jstatico('src', 'dist')
.skipAutoDiscovery()
.generate();