0.1.3 • Published 3 years ago

esbuild-plugin-globcopy v0.1.3

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
3 years ago

esbuild-plugin-globcopy

An esbuild plugin that adds support for copying files from a source directory to a destination directory using glob.

Its primary use case is to copy files from a static directory to a distribution directory on build.

Installation

npm i -D esbuild-plugin-globcopy

Usage

As with the current esbuild plugin API, this plugin requires a custom build script for usage.

import esbuild from 'esbuild'
import globCopy from 'esbuild-plugin-globcopy'

esbuild.build({
  entryPoints: ['src/index.js'],
  bundle: true,
  outdir: 'dist',
  // ...
  plugins: [
    // ...
    globCopy({
      // srcdir: 'static',
      // targets: ['**.png'],
    })
  ]
})

Options

When calling the module, you can pass in an object that contains various options.

srcdir

This input directory to copy files from. Defaults to ./.

targets

Targets can be an array of strings or a single string that provides glob pattern(s). These are resolved relative to srcdir.

outdir

The output directory to copy files to. Defaults to esbuild's outdir if unspecified.