diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx
index 6613314104..47b3885e8b 100644
--- a/docs/config/config-file.mdx
+++ b/docs/config/config-file.mdx
@@ -1,6 +1,6 @@
---
title: "The trigger.config.ts file"
-sidebarTitle: "Configuration"
+sidebarTitle: "trigger.config.ts"
description: "This file is used to configure your project and how it's built."
---
diff --git a/docs/config/extensions/custom.mdx b/docs/config/extensions/custom.mdx
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/docs/config/extensions/esbuild-plugins.mdx b/docs/config/extensions/esbuild-plugins.mdx
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/docs/config/extensions/overview.mdx b/docs/config/extensions/overview.mdx
index 4d5e406a5f..12da54d069 100644
--- a/docs/config/extensions/overview.mdx
+++ b/docs/config/extensions/overview.mdx
@@ -1,5 +1,379 @@
---
-title: "Overview"
-sidebarTitle: "Overview"
-description: "This file is used to configure your project and how it's bundled."
+title: "Build extensions"
+description: "Customize how your project is built and deployed to Trigger.dev with build extensions"
---
+
+Build extension allow you to hook into the build system and customize the build process or the resulting bundle and container image (in the case of deploying). See our [trigger.config.ts reference](/config/config-file#extensions) for more information on how to install and use our built-in extensions. Build extensions can do the following:
+
+- Add additional files to the build
+- Add dependencies to the list of externals
+- Add esbuild plugins
+- Add additional npm dependencies
+- Add additional system packages to the image build container
+- Add commands to run in the image build container
+- Add environment variables to the image build container
+- Sync environment variables to your Trigger.dev project
+
+## Creating a build extension
+
+Build extensions are added to your `trigger.config.ts` file, with a required `name` and optional build hook functions. Here's a simple example of a build extension that just logs a message when the build starts:
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ onBuildStart: async (context) => {
+ console.log("Build starting!");
+ },
+ },
+ ],
+ },
+});
+```
+
+You can also extract that out into a function instead of defining it inline, in which case you will need to import the `BuildExtension` type from the `@trigger.dev/build` package:
+
+
+ You'll need to add the `@trigger.dev/build` package to your `devDependencies` before the below
+ code will work. Make sure it's version matches that of the installed `@trigger.dev/sdk` package.
+
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+import { BuildExtension } from "@trigger.dev/build";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [myExtension()],
+ },
+});
+
+function myExtension(): BuildExtension {
+ return {
+ name: "my-extension",
+ onBuildStart: async (context) => {
+ console.log("Build starting!");
+ },
+ };
+}
+```
+
+## Build hooks
+
+### externalsForTarget
+
+This allows the extension to add additional dependencies to the list of externals for the build. This is useful for dependencies that are not included in the bundle, but are expected to be available at runtime.
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ externalsForTarget: async (target) => {
+ return ["my-dependency"];
+ },
+ },
+ ],
+ },
+});
+```
+
+### onBuildStart
+
+This hook runs before the build starts. It receives the `BuildContext` object as an argument.
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ onBuildStart: async (context) => {
+ console.log("Build starting!");
+ },
+ },
+ ],
+ },
+});
+```
+
+If you want to add an esbuild plugin, you must do so in the `onBuildStart` hook. Here's an example of adding a custom esbuild plugin:
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ onBuildStart: async (context) => {
+ context.registerPlugin({
+ name: "my-plugin",
+ setup(build) {
+ build.onLoad({ filter: /.*/, namespace: "file" }, async (args) => {
+ return {
+ contents: "console.log('Hello, world!')",
+ loader: "js",
+ };
+ });
+ },
+ });
+ },
+ },
+ ],
+ },
+});
+```
+
+You can use the `BuildContext.target` property to determine if the build is for `dev` or `deploy`:
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ onBuildStart: async (context) => {
+ if (context.target === "dev") {
+ console.log("Building for dev");
+ } else {
+ console.log("Building for deploy");
+ }
+ },
+ },
+ ],
+ },
+});
+```
+
+### onBuildComplete
+
+This hook runs after the build completes. It receives the `BuildContext` object and a `BuildManifest` object as arguments. This is where you can add in one or more `BuildLayer`'s to the context.
+
+```ts
+import { defineConfig } from "@trigger.dev/sdk/v3";
+
+export default defineConfig({
+ project: "my-project",
+ build: {
+ extensions: [
+ {
+ name: "my-extension",
+ onBuildComplete: async (context, manifest) => {
+ context.addLayer({
+ id: "more-dependencies",
+ dependencies,
+ });
+ },
+ },
+ ],
+ },
+});
+```
+
+See the [addLayer](#addlayer) documentation for more information on how to use `addLayer`.
+
+## BuildTarget
+
+Can either be `dev` or `deploy`, matching the CLI command name that is being run.
+
+```sh
+npx trigger.dev@latest dev # BuildTarget is "dev"
+npx trigger.dev@latest deploy # BuildTarget is "deploy"
+```
+
+## BuildContext
+
+### addLayer()
+
+
+ The layer to add to the build context. See the [BuildLayer](#buildlayer) documentation for more
+ information.
+
+
+### registerPlugin()
+
+
+ The esbuild plugin to register.
+
+
+
+
+
+ An optional target to register the plugin for. If not provided, the plugin will be registered
+ for all targets.
+
+
+ An optional placement for the plugin. If not provided, the plugin will be registered in place.
+ This allows you to control the order of plugins.
+
+
+
+
+### resolvePath()
+
+Resolves a path relative to the project's working directory.
+
+
+ The path to resolve.
+
+
+```ts
+const resolvedPath = context.resolvePath("my-other-dependency");
+```
+
+### properties
+
+
+ The target of the build, either `dev` or `deploy`.
+
+
+
+
+
+ The runtime of the project (either node or bun)
+
+
+ The project ref
+
+
+ The trigger directories to search for tasks
+
+
+ The build configuration object
+
+
+ The working directory of the project
+
+
+ The root workspace directory of the project
+
+
+ The path to the package.json file
+
+
+ The path to the lockfile (package-lock.json, yarn.lock, or pnpm-lock.yaml)
+
+
+ The path to the trigger.config.ts file
+
+
+ The path to the tsconfig.json file
+
+
+
+
+
+ A logger object that can be used to log messages to the console.
+
+
+## BuildLayer
+
+
+ A unique identifier for the layer.
+
+
+
+ An array of commands to run in the image build container.
+
+```ts
+commands: ["echo 'Hello, world!'"];
+```
+
+These commands are run after packages have been installed and the code copied into the container in the "build" stage of the Dockerfile. This means you cannot install system packages in these commands because they won't be available in the final stage. To do that, please use the `pkgs` property of the `image` object.
+
+
+
+
+
+
+ An array of system packages to install in the image build container.
+
+
+ An array of instructions to add to the Dockerfile.
+
+
+
+
+
+
+
+ Environment variables to add to the image build container, but only during the "build" stage
+ of the Dockerfile. This is where you'd put environment variables that are needed when running
+ any of the commands in the `commands` array.
+
+
+
+
+
+
+
+ Environment variables that should sync to the Trigger.dev project, which will then be avalable
+ in your tasks at runtime. Importantly, these are NOT added to the image build container, but
+ are instead added to the Trigger.dev project and stored securely.
+
+
+
+
+
+ An object of dependencies to add to the build. The key is the package name and the value is the
+ version.
+
+```ts
+dependencies: {
+ "my-dependency": "^1.0.0",
+};
+```
+
+
+
+### examples
+
+Add a command that will echo the value of an environment variable:
+
+```ts
+context.addLayer({
+ id: "my-layer",
+ commands: [`echo $MY_ENV_VAR`],
+ build: {
+ env: {
+ MY_ENV_VAR: "Hello, world!",
+ },
+ },
+});
+```
+
+## Troubleshooting
+
+When creating a build extension, you may run into issues with the build process. One thing that can help is turning on `debug` logging when running either `dev` or `deploy`:
+
+```sh
+npx trigger.dev@latest dev --log-level debug
+npx trigger.dev@latest deploy --log-level debug
+```
+
+Another helpful tool is the `--dry-run` flag on the `deploy` command, which will bundle your project and generate the Containerfile (e.g. the Dockerfile) without actually deploying it. This can help you see what the final image will look like and debug any issues with the build process.
+
+```sh
+npx trigger.dev@latest deploy --dry-run
+```
+
+You should also take a look at our built in extensions for inspiration on how to create your own. You can find them in in [the source code here](https://github.com/triggerdotdev/trigger.dev/tree/main/packages/build/src/extensions).
diff --git a/docs/config/extensions/prisma.mdx b/docs/config/extensions/prisma.mdx
deleted file mode 100644
index 79f7cf9522..0000000000
--- a/docs/config/extensions/prisma.mdx
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: "Prisma"
-sidebarTitle: "Prisma"
-description: "This file is used to configure your project and how it's bundled."
----
diff --git a/docs/mint.json b/docs/mint.json
index 1c7c35cb53..119feff73b 100644
--- a/docs/mint.json
+++ b/docs/mint.json
@@ -1,7 +1,10 @@
{
"$schema": "https://mintlify.com/schema.json",
"name": "Trigger.dev",
- "openapi": ["/openapi.yml", "/v3-openapi.yaml"],
+ "openapi": [
+ "/openapi.yml",
+ "/v3-openapi.yaml"
+ ],
"api": {
"playground": {
"mode": "simple"
@@ -100,23 +103,41 @@
"navigation": [
{
"group": "Getting Started",
- "pages": ["introduction", "quick-start", "how-it-works", "upgrading-beta", "limits"]
+ "pages": [
+ "introduction",
+ "quick-start",
+ "how-it-works",
+ "upgrading-beta",
+ "limits"
+ ]
},
{
"group": "Fundamentals",
"pages": [
{
"group": "Tasks",
- "pages": ["tasks/overview", "tasks/scheduled"]
+ "pages": [
+ "tasks/overview",
+ "tasks/scheduled"
+ ]
},
"triggering",
"apikeys",
- "config/config-file"
+ {
+ "group": "Configuration",
+ "pages": [
+ "config/config-file",
+ "config/extensions/overview"
+ ]
+ }
]
},
{
"group": "Development",
- "pages": ["cli-dev", "run-tests"]
+ "pages": [
+ "cli-dev",
+ "run-tests"
+ ]
},
{
"group": "Deployment",
@@ -126,7 +147,9 @@
"github-actions",
{
"group": "Deployment integrations",
- "pages": ["vercel-integration"]
+ "pages": [
+ "vercel-integration"
+ ]
}
]
},
@@ -138,7 +161,13 @@
"errors-retrying",
{
"group": "Wait",
- "pages": ["wait", "wait-for", "wait-until", "wait-for-event", "wait-for-request"]
+ "pages": [
+ "wait",
+ "wait-for",
+ "wait-until",
+ "wait-for-event",
+ "wait-for-request"
+ ]
},
"queue-concurrency",
"versioning",
@@ -156,7 +185,10 @@
"management/overview",
{
"group": "Tasks API",
- "pages": ["management/tasks/trigger", "management/tasks/batch-trigger"]
+ "pages": [
+ "management/tasks/trigger",
+ "management/tasks/batch-trigger"
+ ]
},
{
"group": "Runs API",
@@ -194,7 +226,9 @@
},
{
"group": "Projects API",
- "pages": ["management/projects/runs"]
+ "pages": [
+ "management/projects/runs"
+ ]
}
]
},
@@ -240,7 +274,11 @@
},
{
"group": "Help",
- "pages": ["community", "help-slack", "help-email"]
+ "pages": [
+ "community",
+ "help-slack",
+ "help-email"
+ ]
},
{
"group": "Frameworks",
@@ -264,11 +302,15 @@
},
{
"group": "Dashboard",
- "pages": ["guides/dashboard/creating-a-project"]
+ "pages": [
+ "guides/dashboard/creating-a-project"
+ ]
},
{
"group": "Migrations",
- "pages": ["guides/use-cases/upgrading-from-v2"]
+ "pages": [
+ "guides/use-cases/upgrading-from-v2"
+ ]
},
{
"group": "Examples",
@@ -290,4 +332,4 @@
"github": "https://github.com/triggerdotdev",
"linkedin": "https://www.linkedin.com/company/triggerdotdev"
}
-}
+}
\ No newline at end of file