Registry / devops / esbuild-copy-files-plugin

esbuild-copy-files-plugin

JSON →
library1.2.1jsnpmunverified

An esbuild plugin to copy files and directories during builds. Current stable version is 1.0.0. The plugin is updated irregularly. Key differentiators: simple API with source/target arrays, copyWithFolder option to preserve or flatten directory structure, minimal dependencies. Suitable for copying static assets like HTML, images, or fonts alongside esbuild bundles.

npm install esbuild-copy-files-plugin
INSTALL
IMPORT
SIG · ESBUILD-COPY-FILES
E
esbuild-copy-files-plugin
devopsjavascriptv1.2.1
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.

copy
import { copy } from 'esbuild-copy-files-plugin'
import copy from 'esbuild-copy-files-plugin'
Use named import; default export not available.
copy
const { copy } = require('esbuild-copy-files-plugin')
const copy = require('esbuild-copy-files-plugin')
CommonJS destructuring required.
copy
import { copy } from 'esbuild-copy-files-plugin'
const copy = require('esbuild-copy-files-plugin').default
No default export in CommonJS.

Shows how to configure the plugin with CJS in esbuild to copy HTML and images preserving folder structure.

const esbuild = require('esbuild'); const { copy } = require('esbuild-copy-files-plugin'); esbuild.build({ entryPoints: ['./src/index.js'], bundle: true, outfile: './dist/bundle.js', plugins: [ copy({ source: ['./src/index.html', './src/assets/images'], target: './dist', copyWithFolder: true }) ] }).catch(() => process.exit(1));
Debug
Known issues
gotchaEmpty source array causes plugin to silently do nothing.
fix
Ensure source array has at least one path.
affects: >=0.0.0
gotchacopyWithFolder: false may overwrite files with same name from different sources.
fix
Use copyWithFolder: true or ensure unique filenames.
affects: >=0.0.0
gotchaRecursive directory copying maintains depth; no depth limit or file filter.
fix
Manually list specific directories or files if full depth is undesirable.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The plugin 'esbuild-copy-files-plugin' is not compatible with esbuild version 0.14.0 or higher. Please update esbuild to a compatible version.
Older plugin versions require esbuild <0.14.0
fix
Update both packages: npm install esbuild@latest esbuild-copy-files-plugin@latest
TypeError: copy is not a function
Importing default instead of named export or using require without destructuring
fix
Use: import { copy } from 'esbuild-copy-files-plugin' or const { copy } = require('esbuild-copy-files-plugin')
ENOENT: no such file or directory, copyfile '...' -> '...'
Source path does not exist or is incorrect
fix
Verify source paths and ensure they exist relative to process.cwd()
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required for plugin integration
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-copy-files-plugin — npm install esbuild-copy-files-plugin · libregistry