Skip to content

esbuild

Installation

bash
npm i -D esbuild
bash
yarn add -D esbuild
bash
pnpm i -D esbuild
bash
bun add -D esbuild

Usage

build.js
js
import esbuild from 'esbuild'

esbuild
  .context({
    entryPoints: ['src/index.ts'],
    bundle: true,
    minify: false,
    sourcemap: true,
    target: ['es2020'],
    format: 'esm',
    outfile: 'dist/runtime-dom.mjs'
  })
  .then((context) => {
    console.log('successfully build by esbuild')

    // 持续监听文件变化 持续进行打包
    return context.watch()
  })