Registry / devops / esbuild-plugin-cp

esbuild-plugin-cp

JSON →
library1.0.2jsnpmunverified

An ESBuild plugin for copying assets during builds. Current version is 1.0.2 (stable). It is a fork of esbuild-plugin-copy with watch removed and exclude support added. Key differentiators: keeps file structure, allows control over destination paths, supports exclusion patterns via glob, and can run only once or on changes. It requires esbuild >= 0.14.0 as a peer dependency.

npm install esbuild-plugin-cp
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-CP
E
esbuild-plugin-cp
devopsjavascriptv1.0.2
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-plugin-cp'
import copy from 'esbuild-plugin-cp'
The package exports a named function 'copy', not a default export.
Options
import type { Options } from 'esbuild-plugin-cp'
import { Options } from 'esbuild-plugin-cp'
Options is a TypeScript type, so use 'import type' for type-only imports.
AssetPair
import type { AssetPair } from 'esbuild-plugin-cp'
AssetPair is another exported interface for configuring asset pairs.
copy (CommonJS)
const { copy } = require('esbuild-plugin-cp')
const copy = require('esbuild-plugin-cp')
In CommonJS, destructure the named export.

ESBuild plugin that copies assets from source to output directory during build. Configures asset pairs with from/to paths and optional exclude patterns.

import { build } from 'esbuild'; import { copy } from 'esbuild-plugin-cp'; (async () => { const res = await build({ entryPoints: ['./src/main.ts'], bundle: true, outfile: './dist/main.js', plugins: [ copy({ assets: { from: ['./assets/*'], to: ['./assets'], exclude: ['.assets/*.txt'], }, }), ], }); console.log('Build succeeded'); })();
Debug
Known issues
gotchaGlob patterns do not expand directories by default. Using 'dir/*' only matches files directly inside 'dir', not nested files. Use 'dir/**/*' to match recursively.
fix
Use 'dir/**/*' instead of 'dir/*' to include nested files.
affects: >=0.0.0
gotchaThe plugin uses fs.copyFileSync for each file, which may be slow for large numbers of files.
fix
Consider alternative plugins that support streaming or parallel copying for large asset directories.
affects: >=0.0.0
breakingForked from esbuild-plugin-copy: watch functionality was removed. If you need watch mode during development, this plugin does not support it.
fix
Use the original esbuild-plugin-copy if watch mode is required, or implement your own watch logic separately.
affects: >=0.0.0
deprecatedThe 'resolveFrom' option may change in future versions; currently it accepts 'cwd' or defaults to the build output directory.
fix
Stay updated with changelog for any changes to resolveFrom behavior.
affects: >=1.0.0
Errors
Common errors & fixes
No files matched using current glob pattern: ./node_modules/tinymce/skins/*, maybe you need to configure globby by options.globbyOptions?
Using a non-recursive glob pattern 'dir/*' when directory is empty or has only subdirectories.
fix
Use recursive pattern 'dir/**/*' or configure globby.deep option to allow matching nested files.
Cannot find module 'esbuild-plugin-cp' or its corresponding type declarations.
Package not installed or missing from node_modules.
fix
Run 'npm install esbuild-plugin-cp --save-dev' (or pnpm/yarn equivalent) to install the package.
TypeError: (0 , esbuild_plugin_cp.copy) is not a function
Incorrect import syntax, likely using default import instead of named import.
fix
Use named import: import { copy } from 'esbuild-plugin-cp';
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency - the plugin is designed to run alongside esbuild
globbyrequiredInternal dependency for glob pattern matching (used via options.globbyOptions)
fs-extraoptionalInternal dependency for file copy operations (but uses fs.copyFileSync directly, so might not be needed)
@types/globbyoptionalType definitions for globby options in TypeScript
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-cp — npm install esbuild-plugin-cp · libregistry