Use defineConfig from tsdown to specify build configurations for one or more entry points. The configuration accepts an array of objects, allowing you to define different build targets (e.g., Node.js vs. Browser) within the same project.
Available configuration options per entry point:
entry: An array of strings representing the input files.format: An array of output formats (e.g., "esm", "cjs").platform: The target environment (e.g., "node", "browser").dts: Boolean to enable/disable TypeScript declaration generation.sourcemap: Boolean to enable/disable sourcemap generation.minify: Boolean to enable/disable code minification.
import { defineConfig } from "tsdown";
export default defineConfig([
{
entry: ["./src/index.ts"],
format: ["esm", "cjs"],
platform: "node",
dts: true,
sourcemap: true,
},
{
entry: ["./src/core.ts"],
platform: "browser",
dts: true,
minify: true,
sourcemap: true,
},
]);