Configuration
Configuration Files
PS Guard looks for configuration in the following order:
- ps-guard.config.ts
- ps-guard.config.js
- ps-guard.config.json
- ps-guard field in package.json
Configuration Interface
typescript
interface PSGuardConfig { // URL to audit (overridden by CLI --url) url?: string;
// Device emulation device?: "mobile" | "desktop"; // Default: "mobile"
// Minimum Lighthouse score (0-100) minScore?: number; // Default: 90
// Web Vitals thresholds thresholds?: { lcp?: number; // Default: 2500 (ms) cls?: number; // Default: 0.1 inp?: number; // Default: 200 (ms) ttfb?: number; // Default: 800 (ms) fcp?: number; // Default: 1800 (ms) };
// Sitemap options sitemap?: string; // Sitemap URL maxUrls?: number; // Default: 50
// Reporting html?: boolean; // Generate HTML report reportDir?: string; // Default: "./ps-guard-report" json?: boolean; // JSON output
// Preset name preset?: "nextjs" | "landing-page" | "marketing-site";
// CI mode ci?: boolean;
// Retry attempts retries?: number; // Default: 1}Example Configuration File
typescript
// ps-guard.config.tsexport default { url: "https://your-site.com", device: "mobile", minScore: 90,
thresholds: { lcp: 2500, cls: 0.1, inp: 200, ttfb: 800, fcp: 1800, },
html: true, reportDir: "./reports/performance", retries: 2,};Package.json Configuration
json
{ "name": "my-project", "version": "1.0.0", "ps-guard": { "device": "mobile", "minScore": 90, "thresholds": { "lcp": 2500, "cls": 0.1 } }}Config Priority
Configuration values are merged in this order (highest priority first):
- CLI arguments (--url, --device, etc.)
- Config file (ps-guard.config.ts/js/json)
- package.json "ps-guard" field
- Preset values (if --preset is used)
- Built-in defaults
CLI arguments always win. This lets you override config file values for specific CI jobs or local testing.