Skip to main content

Configuration

Set up your Baeta project configuration in a few simple steps.

Configuration File

Baeta looks for a configuration file in your project root with one of these names:

  • baeta.js
  • .baeta.js
  • baeta.mjs
  • .baeta.mjs
  • baeta.ts (requires @baeta/compiler)
  • .baeta.ts (requires @baeta/compiler)
note

While Baeta supports CommonJS, the configuration file must use ESM. If using .js file, ensure "type": "module" is set in your package.json, otherwise use the .mjs file extension.

Basic Configuration

1. Define Schema Location

First, specify where your GraphQL schemas are located:

import { defineConfig } from "@baeta/cli";

export default defineConfig({
graphql: {
schemas: ["src/**/*.gql"], // Location of your GraphQL schemas
},
});

2. Configure Build Settings

Add compiler configuration to specify your app's entry point and build output:

import { defineConfig } from "@baeta/cli";

export default defineConfig({
graphql: {
schemas: ["src/**/*.gql"],
modulesDir: "src/modules",
},
compiler: {
src: "src/app.ts", // Your application entry point
dist: "dist", // Build output directory
},
});

3.Add Package.json Scripts

{
"scripts": {
"build": "baeta build --generate",
"generate": "baeta generate",
"start": "baeta build --watch --generate --onSuccess='node --enable-source-maps dist/app.js'"
}
}

These scripts provide:

  • build: Builds your project and generates necessary files
  • generate: Updates GraphQL types and resolvers
  • start: Runs development server with hot reload
tip

If you're using Bun or Deno you might prefer to run the TypeScript source directly. In that case replace start with:

{
"start:bun": "baeta generate --watch --run='bun --watch --inspect src/app.ts'",
"start:deno": "baeta generate --watch --run='deno --watch --inspect --allow-net --allow-read --allow-env src/app.ts'"
}
tip

Run baeta generate --help or baeta build --help to see all command options

Next Steps

Once configured, you're ready to create your first module.