Config File
Overview
Section titled “Overview”A Sigil config file is a TypeScript module that exports an Environment as its default export. Sigil dynamically imports this file at runtime using Bun’s native TypeScript support — no build step required.
File location
Section titled “File location”By default, Sigil looks for sigil.config.ts in the current working directory. Override with the --config flag:
sigil up --config ./configs/staging.config.tsStructure
Section titled “Structure”import { Environment, Postgres, Service } from "sigil";import path from "path";
const root = import.meta.dir;
const env = new Environment("my-app");
// Add entities in dependency orderconst db = env.add(new Postgres("db", { ... }));env.add(new Service("api", { ... }));
// Must be the default exportexport default env;Key patterns
Section titled “Key patterns”import.meta.dir
Section titled “import.meta.dir”Use import.meta.dir to get the directory containing the config file. This makes paths work correctly regardless of where sigil up is run from:
const root = import.meta.dir;
new Postgres("db", { initSql: path.join(root, "db/schema.sql"),});
new Service("api", { cwd: path.join(root, "backend"),});Dependency wiring
Section titled “Dependency wiring”Entities that are added first start first. Use references to earlier entities to wire up dependencies:
const db = env.add(new Postgres("db", { ... }));
// db.connectionString is available immediately (computed from config)env.add(new Service("api", { env: { DATABASE_URL: db.connectionString },}));Multiple configs
Section titled “Multiple configs”You can have multiple config files for different scenarios:
sigil.config.ts # full stacksigil.config.db-only.ts # just the databasesigil.config.test.ts # test environment with different portssigil up --config sigil.config.db-only.tsWhat gets imported
Section titled “What gets imported”Sigil does:
const mod = await import(configPath);const env = mod.default; // must be an EnvironmentSide effects in your config file (like console.log) will execute when the config is imported.