Skip to content
Advertisement

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?

Advertisement

Answer

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));
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement