Docs menu
Customizing the build
Customize the Bun build on Primcloud: build scripts, project.toml settings, tools that expect Node.js, and system packages.
On this page
Most Bun apps need no custom build steps. When yours does, use your package.json scripts, a few settings in project.toml, or system packages.
Build hooks#
The build runs these package.json scripts with bun run, in order, skipping any you haven't defined. A script that exits non-zero fails the build.
heroku-prebuildheroku-buildif defined, otherwisebuildheroku-postbuild
{
"scripts": {
"build": "bun build ./src/server.ts --outdir ./dist --target bun",
"heroku-postbuild": "bun scripts/generate-manifest.ts",
"start": "bun dist/server.js"
}
}
- Bundling and framework builds go in
build. devDependenciesare installed for all three scripts and removed once they finish.- Define
heroku-buildonly when yourbuildscript is for local development and shouldn't run on Primcloud.
Build settings#
There's no separate install step to customize: everything installs from your lockfile, so change what's installed by updating package.json and running bun install locally.
Skip the build scripts:
[_]
schema-version = "0.2"
[com.primcloud.buildpacks.bun]
enabled = false
Keep everything in node_modules. After your build scripts, the build removes your devDependencies and any package your lockfile doesn't list. To skip that:
[_]
schema-version = "0.2"
[com.primcloud.buildpacks.bun]
actions.prune_dev_dependencies = false
If your app needs a package at runtime, moving it to dependencies and committing the lockfile is usually the better fix.
Tools that expect Node.js#
A Bun app has no node. Most build tools run fine under Bun, including ones that start with node, like Vite: Bun runs them. To be explicit, use Bun's --bun flag:
{
"scripts": {
"build": "bun run --bun vite build"
}
}
Debian packages#
When your app needs system libraries or command-line tools that aren't already installed, list them in a project.toml at the root of your repo:
[_]
schema-version = "0.2"
[com.heroku.buildpacks.deb-packages]
install = [
"libvips-dev",
"imagemagick",
"ffmpeg",
]
Each entry is a package name from the Ubuntu 24.04 archive. Its programs and libraries are available during the build and at runtime.
Advanced options (rarely needed):
- Skip a package's dependencies:
{ name = "some-package", skip_dependencies = true } - Force a reinstall:
{ name = "some-package", force = true } - Install from a URL:
download = ["https://example.com/package-1.2.3.deb"] - Add a package repository: a
[[com.heroku.buildpacks.deb-packages.sources]]table withuri,suites,components,arch, andsigned_by(the repository's key as an ASCII-armored PGP block).
Note
The build doesn't read an Aptfile. If your repo has one, the build log warns you and nothing in it is installed. Move the packages into project.toml as shown above.