'How to translate this esbuild CLI sentence to JS file

I managed to construct this esbuild CLI sentence, but I am struggling to transform it to a JS build file:

esbuild out1=src/out1.ts out2=src/out2.ts out3=src/out3.ts --bundle --outdir=dist --watch --minify

This takes 3 different files and bundles it to 3 different files, that is exactly what I want. But now I want to add more bundle rules, and I don't want to keeping adding to this and have a separate file for the bundle.

Someone can point me to the docs or giving some hints on how to achieve it?



Solution 1:[1]

It was the silliest thing. Just add them as an entryPoints and add the left ones to the esbuild.build config:

import { build } from 'esbuild';

build({
  entryPoints: ['src/out1.ts', "src/out2.ts", "src/out3.ts"],
  outdir: 'dist',
  minify: true,
  bundle: true,
  watch: true,
  target: 'es2020',
}).catch(error => process.exit(1));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emel