Skip to content

CLI Configuration

Minimajs is configured via a minimajs.config.ts file in the root of your project.

ts
import { defineConfig } from "@minimajs/cli";

export default defineConfig({
  entry: ["src/index.ts", "src/**/module.ts"],
  outdir: "dist",
});

Options

OptionTypeDefaultDescription
entrystring[]["src/index.ts", "src/**/module.ts"]Entry points or glob patterns
outdirstring"dist"Output directory
cleanbooleantrueClean output directory before each build
checkbooleantrueRun TypeScript type checking in watch mode
minifybooleanfalseMinify output
sourcemapbooleanfalseEmit source maps
tsconfigstring"tsconfig.json"Path to tsconfig
watchbooleanfalseWatch for changes
runbooleanfalseRun the output after build
importstring[][]Additional entry points to import at startup
loaderRecord<string, Loader>{}Custom esbuild loaders
killSignalNodeJS.Signals"SIGTERM"Signal used to stop the running process
pluginsMinimaPlugin[][]Minimajs CLI plugins
esbuildEsbuildOverridesRaw esbuild options (merged last)

Plugins

Plugins extend the CLI build pipeline. A plugin can contribute entry glob patterns and/or hook into the esbuild lifecycle via setup.

ts
import { defineConfig } from "@minimajs/cli";
import type { MinimaPlugin } from "@minimajs/cli";

const myPlugin = (): MinimaPlugin => ({
  name: "my-plugin",
  entry: ["src/**/worker.ts"],
});

export default defineConfig({
  plugins: [myPlugin()],
});

With the above plugin, any src/*/worker.ts file is automatically picked up as a build entry — no manual registration needed.

Hooking into esbuild

If a plugin needs to transform files or intercept the build, implement setup:

ts
const myPlugin = (): MinimaPlugin => ({
  name: "my-plugin",
  entry: ["src/**/worker.ts"],
  setup(build) {
    build.onLoad({ filter: /\.txt$/ }, (args) => ({
      contents: `export default ${JSON.stringify(args.path)}`,
    }));
  },
});

Plugins without setup are not registered with esbuild — only their entry patterns are used.

esbuild Passthrough

Pass raw esbuild options that are merged into the final build config. Managed options (entryPoints, outdir, plugins, metafile, bundle, platform, format, splitting) cannot be overridden.

ts
import { defineConfig } from "@minimajs/cli";

export default defineConfig({
  esbuild: {
    define: {
      "process.env.VERSION": JSON.stringify("1.0.0"),
    },
    banner: {
      js: "// generated by minimajs",
    },
  },
});