File Targets
File recipes are conditional—they only run if the output file is missing or any dependency file has been modified.
Basic Syntax
Section titled “Basic Syntax”file dist/app.js: src/index.ts esbuild src/index.ts --outfile=dist/app.jsThe recipe name is the output file path. Dependencies are listed after the colon.
Multiple Dependencies
Section titled “Multiple Dependencies”file dist/bundle.js: src/index.ts src/utils.ts src/helpers.ts esbuild src/index.ts --bundle --outfile=dist/bundle.jsGlob Patterns
Section titled “Glob Patterns”Use patterns to match multiple files:
file dist/app.js: src/**/*.ts esbuild src/index.ts --bundle --outfile=dist/app.jsSupported patterns:
*- Match any characters except/**- Match any characters including/(recursive)?- Match single character[abc]- Match character class[a-z]- Match character range
Chained Builds
Section titled “Chained Builds”File recipes can chain together for multi-stage builds:
# Stage 1: Compile TypeScriptfile dist/compiled.js: src/**/*.ts tsc --outFile dist/compiled.js
# Stage 2: Minify (depends on Stage 1 output)file dist/app.min.js: dist/compiled.js terser dist/compiled.js -o dist/app.min.js
# Task to trigger the full buildtask build: [dist/app.min.js] echo "Build complete!"When you run jake build, Jake automatically:
- Checks if
dist/compiled.jsneeds rebuilding - Checks if
dist/app.min.jsneeds rebuilding - Only runs the necessary stages
Examples
Section titled “Examples”CSS Compilation
Section titled “CSS Compilation”file dist/styles.css: src/styles.scss sass src/styles.scss dist/styles.cssMulti-file Bundle
Section titled “Multi-file Bundle”file dist/bundle.js: src/**/*.js lib/**/*.js cat src/*.js lib/*.js > dist/bundle.jsBinary Compilation
Section titled “Binary Compilation”cc = "gcc"cflags = "-Wall -O2"
file app: main.c utils.c {{cc}} {{cflags}} -o app main.c utils.cWhen to Use File Targets
Section titled “When to Use File Targets”Use file when:
- The recipe produces an output file
- You want incremental builds (skip if output is up-to-date)
- Build times matter and you want to avoid unnecessary work
Use task when:
- The command should run every time
- There’s no specific output file