Registry / devops / esbuild-plugin-copy-watch

esbuild-plugin-copy-watch

JSON →
library2.3.1jsnpmunverified

An esbuild plugin that copies files from specified source patterns to a destination directly within the esbuild build process. Version 2.3.1 is the current stable release, with active maintenance as of 2024. It supports glob patterns and optional exclusion filters, allowing developers to copy assets like static files, configs, or HTML alongside bundled JavaScript output. Unlike manual copy steps or post-build scripts, this plugin integrates with esbuild's watch mode to re-copy files on each rebuild. It also offers a `forceCopyOnRebuild` option to force recopy even when sources are unchanged. TypeScript types are included for better IDE support.

npm install esbuild-plugin-copy-watch
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-COP
E
esbuild-plugin-copy-watch
devopsjavascriptv2.3.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.

default
import copy from 'esbuild-plugin-copy-watch'
const copy = require('esbuild-plugin-copy-watch')
ESM-only; CommonJS require will not work. Use import or dynamic import.
copyPlugin (if named export)
import { copy as copyPlugin } from 'esbuild-plugin-copy-watch'
Export is default only; there is no named export. Verified that only default export exists.
with TypeScript
import copy from 'esbuild-plugin-copy-watch'
import copy from 'esbuild-plugin-copy-watch/dist/index.js'
TypeScript types are bundled in package; direct import from module root is correct.

Copies files matching 'static/**' to a 'static' directory in the output, and copies config JS files excluding 'private.js', with no force recopy.

import esbuild from 'esbuild' import copy from 'esbuild-plugin-copy-watch' await esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'dist/bundle.js', plugins: [ copy({ paths: [ { from: 'static/**', to: 'static' }, { from: ['config/*.js', '!config/private.js'], to: 'config' }, ], forceCopyOnRebuild: false, }) ] })
Debug
Known issues
breakingDefault export changed from named export to default export in v2.0.0
fix
Use default import: import copy from 'esbuild-plugin-copy-watch'
affects: >=2.0.0 <2.0.0
deprecatedThe option 'forceCopyOnRebuild' may be removed in future versions; no deprecation warning yet but usage is discouraged
fix
Set forceCopyOnRebuild to true if needed; see docs for alternative
affects: >=2.0.0
gotchaPlugin requires esbuild >=0.8.0; older esbuild versions may cause build failures
fix
Update esbuild to version 0.8.0 or later
affects: >=2.0.0
gotchaGlob patterns with negation must be in array form; passing a string with negation will not work
fix
Wrap pattern and negation in an array: ['src/**', '!src/private.js']
affects: >=2.0.0
Errors
Common errors & fixes
Error: Could not resolve 'esbuild-plugin-copy-watch'
Package not installed or missing from node_modules
fix
Run: npm install esbuild-plugin-copy-watch
TypeError: copy is not a function
Using CommonJS require instead of ESM import, or calling the default export incorrectly
fix
Use import copy from 'esbuild-plugin-copy-watch' and ensure your project is ESM (type: module in package.json)
Error: esbuild version 0.8.0 or higher is required
Plugin requires esbuild >=0.8.0; current installed esbuild is older
fix
Update esbuild: npm install esbuild@latest
Upgrade
Version history
2.3.1latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required to function as a plugin; the plugin relies on esbuild's plugin API and watch mode
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-copy-watch — npm install esbuild-plugin-copy-watch · libregistry