trigger.config.ts file is used to configure your Trigger.dev project. It is a TypeScript file at the root of your project that exports a default configuration object. Here’s an example:
trigger.config.ts
- Specifying where your trigger tasks are located using the
dirsoption. - Setting the default retry settings.
- Configuring OpenTelemetry instrumentations.
- Customizing the build process.
- Adding global task lifecycle functions.
The config file is bundled with your project, so code imported in the config file is also bundled,
which can have an effect on build times and cold start duration. One important qualification is
anything defined in the
build config is automatically stripped out of the config file, and
imports used inside build config with be tree-shaken out.Dirs
You can specify the directories where your tasks are located using thedirs option:
trigger.config.ts
dirs option, we will automatically detect directories that are named trigger in your project, but we recommend specifying the directories explicitly. The dirs option is an array of strings, so you can specify multiple directories if you have tasks in multiple locations.
We will search for TypeScript and JavaScript files in the specified directories and include them in the build process. We automatically exclude files that have .test or .spec in the name, but you can customize this by specifying glob patterns in the ignorePatterns option:
trigger.config.ts
Custom tsconfig path
You can specify a custom path to your tsconfig file. This is useful if you have a custom tsconfig file that you want to use.trigger.config.ts
Lifecycle functions
You can add lifecycle functions to get notified when any task starts, succeeds, or fails usingonStart, onSuccess and onFailure:
trigger.config.ts

