Skip to content

Commit 02b622c

Browse files
committed
Build extension guide WIP
1 parent e813803 commit 02b622c

File tree

6 files changed

+134
-22
lines changed

6 files changed

+134
-22
lines changed

docs/config/config-file.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "The trigger.config.ts file"
3-
sidebarTitle: "Configuration"
3+
sidebarTitle: "trigger.config.ts"
44
description: "This file is used to configure your project and how it's built."
55
---
66

docs/config/extensions/custom.mdx

Whitespace-only changes.

docs/config/extensions/esbuild-plugins.mdx

Whitespace-only changes.
Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
11
---
2-
title: "Overview"
3-
sidebarTitle: "Overview"
4-
description: "This file is used to configure your project and how it's bundled."
2+
title: "Build extensions"
3+
description: "Customize how your project is built and deployed to Trigger.dev with build extensions"
54
---
5+
6+
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:
7+
8+
- Add additional files to the build
9+
- Add esbuild plugins
10+
- Add additional npm dependencies
11+
- Add additional system packages to the image build container
12+
- Add commands to run in the image build container
13+
- Add environment variables to the image build container
14+
- Sync environment variables to your Trigger.dev project
15+
16+
## Creating a build extension
17+
18+
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:
19+
20+
```ts
21+
import { defineConfig } from "@trigger.dev/sdk/v3";
22+
23+
export default defineConfig({
24+
project: "my-project",
25+
build: {
26+
extensions: [
27+
{
28+
name: "my-extension",
29+
onBuildStart: async (context) => {
30+
console.log("Build starting!");
31+
},
32+
},
33+
],
34+
},
35+
});
36+
```
37+
38+
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:
39+
40+
<Note>
41+
You'll need to add the `@trigger.dev/build` package to your `devDependencies` before the below
42+
code will work. Make sure it's version matches that of the installed `@trigger.dev/sdk` package.
43+
</Note>
44+
45+
```ts
46+
import { defineConfig } from "@trigger.dev/sdk/v3";
47+
import { BuildExtension } from "@trigger.dev/build";
48+
49+
export default defineConfig({
50+
project: "my-project",
51+
build: {
52+
extensions: [myExtension()],
53+
},
54+
});
55+
56+
function myExtension(): BuildExtension {
57+
return {
58+
name: "my-extension",
59+
onBuildStart: async (context) => {
60+
console.log("Build starting!");
61+
},
62+
};
63+
}
64+
```
65+
66+
## Build hooks
67+
68+
### onBuildStart
69+
70+
### onBuildComplete
71+
72+
## Reference
73+
74+
### BuildContext
75+
76+
### BuildLayer
77+
78+
## Troubleshooting
79+
80+
Describe how to use --dry-run

docs/config/extensions/prisma.mdx

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/mint.json

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"$schema": "https://mintlify.com/schema.json",
33
"name": "Trigger.dev",
4-
"openapi": ["/openapi.yml", "/v3-openapi.yaml"],
4+
"openapi": [
5+
"/openapi.yml",
6+
"/v3-openapi.yaml"
7+
],
58
"api": {
69
"playground": {
710
"mode": "simple"
@@ -100,23 +103,41 @@
100103
"navigation": [
101104
{
102105
"group": "Getting Started",
103-
"pages": ["introduction", "quick-start", "how-it-works", "upgrading-beta", "limits"]
106+
"pages": [
107+
"introduction",
108+
"quick-start",
109+
"how-it-works",
110+
"upgrading-beta",
111+
"limits"
112+
]
104113
},
105114
{
106115
"group": "Fundamentals",
107116
"pages": [
108117
{
109118
"group": "Tasks",
110-
"pages": ["tasks/overview", "tasks/scheduled"]
119+
"pages": [
120+
"tasks/overview",
121+
"tasks/scheduled"
122+
]
111123
},
112124
"triggering",
113125
"apikeys",
114-
"config/config-file"
126+
{
127+
"group": "Configuration",
128+
"pages": [
129+
"config/config-file",
130+
"config/extensions/overview"
131+
]
132+
}
115133
]
116134
},
117135
{
118136
"group": "Development",
119-
"pages": ["cli-dev", "run-tests"]
137+
"pages": [
138+
"cli-dev",
139+
"run-tests"
140+
]
120141
},
121142
{
122143
"group": "Deployment",
@@ -126,7 +147,9 @@
126147
"github-actions",
127148
{
128149
"group": "Deployment integrations",
129-
"pages": ["vercel-integration"]
150+
"pages": [
151+
"vercel-integration"
152+
]
130153
}
131154
]
132155
},
@@ -138,7 +161,13 @@
138161
"errors-retrying",
139162
{
140163
"group": "Wait",
141-
"pages": ["wait", "wait-for", "wait-until", "wait-for-event", "wait-for-request"]
164+
"pages": [
165+
"wait",
166+
"wait-for",
167+
"wait-until",
168+
"wait-for-event",
169+
"wait-for-request"
170+
]
142171
},
143172
"queue-concurrency",
144173
"versioning",
@@ -156,7 +185,10 @@
156185
"management/overview",
157186
{
158187
"group": "Tasks API",
159-
"pages": ["management/tasks/trigger", "management/tasks/batch-trigger"]
188+
"pages": [
189+
"management/tasks/trigger",
190+
"management/tasks/batch-trigger"
191+
]
160192
},
161193
{
162194
"group": "Runs API",
@@ -194,7 +226,9 @@
194226
},
195227
{
196228
"group": "Projects API",
197-
"pages": ["management/projects/runs"]
229+
"pages": [
230+
"management/projects/runs"
231+
]
198232
}
199233
]
200234
},
@@ -240,7 +274,11 @@
240274
},
241275
{
242276
"group": "Help",
243-
"pages": ["community", "help-slack", "help-email"]
277+
"pages": [
278+
"community",
279+
"help-slack",
280+
"help-email"
281+
]
244282
},
245283
{
246284
"group": "Frameworks",
@@ -264,11 +302,15 @@
264302
},
265303
{
266304
"group": "Dashboard",
267-
"pages": ["guides/dashboard/creating-a-project"]
305+
"pages": [
306+
"guides/dashboard/creating-a-project"
307+
]
268308
},
269309
{
270310
"group": "Migrations",
271-
"pages": ["guides/use-cases/upgrading-from-v2"]
311+
"pages": [
312+
"guides/use-cases/upgrading-from-v2"
313+
]
272314
},
273315
{
274316
"group": "Examples",
@@ -290,4 +332,4 @@
290332
"github": "https://github.com/triggerdotdev",
291333
"linkedin": "https://www.linkedin.com/company/triggerdotdev"
292334
}
293-
}
335+
}

0 commit comments

Comments
 (0)