Registry / devops / esbuild-copy-plugin

esbuild-copy-plugin

JSON →
library1.0.0jsnpmunverified

A plugin for esbuild that copies files or directories from one location to another during the build process. Version 1.0.0 is the current release. It provides a simple API to define copy operations using `from` and `to` paths. Unlike general-purpose tools like `cpy` or `copy-webpack-plugin`, this is tightly integrated with esbuild's plugin system and runs as part of the build lifecycle. The package is lightweight, with no dependencies. It is maintained, but has a low release cadence.

npm install esbuild-copy-plugin
INSTALL
IMPORT
SIG · ESBUILD-COPY-PLUGI
E
esbuild-copy-plugin
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import copy from 'esbuild-copy-plugin'
The package exports a single default function that returns an esbuild plugin.
default
const copy = require('esbuild-copy-plugin')
const { copy } = require('esbuild-copy-plugin')
Requiring with destructuring fails because the module exports a default, not named exports.

Basic usage: copies all files from ./public to ./dist (the output directory) during the esbuild build.

import esbuild from 'esbuild'; import copy from 'esbuild-copy-plugin'; await esbuild.build({ entryPoints: ['./src/index.js'], bundle: true, outfile: './dist/index.js', plugins: [ copy({ from: './public', to: '.' }), ], });
Debug
Known issues
gotchaThe `from` path is relative to the current working directory, not the esbuild build's root.
fix
Use absolute paths or ensure your working directory is the project root.
affects: >=1.0.0
gotchaThe `to` path is relative to the output directory (outfile/outdir's parent by default).
fix
Specify 'to' relative to outdir, e.g., if outdir is './dist', to: '.' places files directly in './dist'.
affects: >=1.0.0
deprecatedNo known deprecations.
fix
N/A
affects: >=1.0.0
Errors
Common errors & fixes
Error: The plugin "copy" returned a copy result but the build finished.
The copy operation completed after esbuild finished because it's asynchronous but not awaited.
fix
Make sure esbuild build is awaited (since esbuild 0.17+ build returns a promise).
TypeError: copy is not a function
Using `import { copy } from 'esbuild-copy-plugin'` instead of default import.
fix
Use `import copy from 'esbuild-copy-plugin'` or `const copy = require('esbuild-copy-plugin')`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-copy-plugin — npm install esbuild-copy-plugin · libregistry