Registry / devops / esbuild-plugin-file-copy

esbuild-plugin-file-copy

JSON →
library2.0.0-next.0jsnpmunverified

An esbuild plugin that copies specified files and directories (including glob patterns) to the output folder after bundling. Current version 2.0.0-next.0 is a pre-release. Release cadence is irregular; the plugin is stable but not widely used. Differentiators: lightweight, no external dependencies, supports both exact file paths and glob patterns, and works alongside esbuild without altering the bundling process. TypeScript types included. Suitable for including static assets like images, configuration files, or any non-code artifacts in the esbuild output.

npm install esbuild-plugin-file-copy
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-FIL
E
esbuild-plugin-file-copy
devopsjavascriptv2.0.0-next.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.

fileCopyPlugin
import { fileCopyPlugin } from 'esbuild-plugin-file-copy'
const fileCopyPlugin = require('esbuild-plugin-file-copy')
Package is ESM-only; CommonJS require will fail.
Plugin (type)
import type { Plugin } from 'esbuild'
Plugin type is imported from esbuild, not from this package. This package exports only the fileCopyPlugin function.
default import
import fileCopyPlugin from 'esbuild-plugin-file-copy'
import { default as fileCopyPlugin } from 'esbuild-plugin-file-copy'
Package exports a named export; default import works in ESM but is not recommended. Use named import for clarity.

Demonstrates configuring fileCopyPlugin with both explicit file paths and glob patterns during esbuild build.

import { fileCopyPlugin } from 'esbuild-plugin-file-copy'; import * as esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['src/index.js'], outdir: 'dist', bundle: true, plugins: [ fileCopyPlugin({ inputs: [ { from: 'static/favicon.ico', to: 'dist' }, { from: 'static/robots.txt', to: 'dist' } ], globs: [ { from: 'public/**/*.png', to: 'dist/assets' } ] }) ] });
Debug
Known issues
breakingVersion 2.0.0 is a pre-release (next) with potential API changes from 1.x.
fix
Use 1.x if stability needed; check changelog for changes.
affects: 2.0.0-next.0
gotchaThe 'from' path in 'inputs' and 'globs' must be relative to the current working directory or absolute; relative paths are resolved from process.cwd().
fix
Use absolute paths or ensure consistency with esbuild's working directory.
affects: >=1.0.0
gotchaGlob patterns in 'globs' array use the 'glob' package internally; patterns are matched against the file system after esbuild finishes bundling, so any files created during build (e.g., codegen) may not be copied.
fix
Only copy files that exist before the build starts or ensure they are present before the plugin runs.
affects: >=1.0.0
deprecatedThe 'globs' option may be deprecated in future versions in favor of 'inputs' with glob support? No official deprecation yet, but the API split can be confusing.
fix
Use 'inputs' for single files; 'globs' for patterns; check future releases.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-file-copy'
Package not installed or used in a CommonJS environment (require).
fix
Install as dev dependency: npm install -D esbuild-plugin-file-copy. Use ESM imports: import { fileCopyPlugin } from 'esbuild-plugin-file-copy'.
TypeError: fileCopyPlugin is not a function
Incorrect import (e.g., wrong export name) or using the plugin without calling it as a function in the plugins array.
fix
Ensure correct import: import { fileCopyPlugin } from 'esbuild-plugin-file-copy'. Then use as a function call: fileCopyPlugin({...}) inside the plugins array.
Error: ENOENT: no such file or directory, copyfile '...' -> '...'
Source file specified in 'inputs' or 'globs' does not exist.
fix
Verify the 'from' path is correct and the file exists; use absolute paths or adjust relative path from working directory.
Upgrade
Version history
2.0.0-next.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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