Web Project
A complete Jakefile for a modern web project with TypeScript, testing, and deployment.
# Project configurationapp_name = "myapp"node_env = "development"
# Load environment variables@dotenv@dotenv ".env.local"
# Export for all commands@export NODE_ENV={{node_env}}
# === Development ===
@defaulttask dev: @description "Start development server" @needs node npm npm run dev
task install: @description "Install dependencies" @if exists(node_modules) echo "Dependencies installed, run 'jake install-fresh' to reinstall" @else npm install @end
task install-fresh: @description "Clean install dependencies" rm -rf node_modules npm install
# === Build ===
@group buildfile dist/app.js: src/**/*.ts tsconfig.json @description "Compile TypeScript" npx tsc
@group buildfile dist/styles.css: src/**/*.css @description "Bundle CSS" npx postcss src/index.css -o dist/styles.css
@group buildtask build: [dist/app.js, dist/styles.css] @description "Build everything" echo "Build complete!"
# === Testing ===
@group testtask test: @description "Run all tests" npm test
@group testtask test-watch: @description "Run tests in watch mode" npm test -- --watch
@group testtask lint: @description "Run linter" npm run lint
@group testtask typecheck: @description "Type check without emitting" npx tsc --noEmit
task check: [lint, typecheck, test] @description "Run all checks" echo "All checks passed!"
# === Deployment ===
@group deploytask deploy: [build, check] @description "Deploy to production" @confirm "Deploy to production?" @require DEPLOY_TOKEN @if env(CI) echo "Deploying from CI..." ./scripts/deploy.sh @else echo "Deploying locally..." rsync -avz dist/ server:/var/www/{{app_name}}/ @end
@group deploytask deploy-staging: [build] @description "Deploy to staging" rsync -avz dist/ staging:/var/www/{{app_name}}/
# === Utilities ===
task clean: @description "Remove build artifacts" rm -rf dist/ rm -rf .cache/
task clean-all: [clean] @description "Remove everything including node_modules" rm -rf node_modules/
task format: @description "Format code" npx prettier --write "src/**/*.{ts,css,json}"
# === Docker ===
@group dockertask docker-build: @description "Build Docker image" @needs docker docker build -t {{app_name}}:latest .
@group dockertask docker-run: [docker-build] @description "Run Docker container" docker run -p 3000:3000 {{app_name}}:latest# Start developmentjake dev
# Build projectjake build
# Run all checks before commitjake check
# Deploy to stagingjake deploy-staging
# Deploy to productionjake deploy
# Clean and rebuildjake clean && jake build