{"id":25269,"library":"esbuild-copy-files-plugin","title":"esbuild-copy-files-plugin","description":"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.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/whatdoyouseedoc/esbuild-copy-files-plugin","tags":["javascript","esbuild","copy","files","plugin"],"install":[{"cmd":"npm install esbuild-copy-files-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-copy-files-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-copy-files-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin integration","package":"esbuild","optional":false}],"imports":[{"note":"Use named import; default export not available.","wrong":"import copy from 'esbuild-copy-files-plugin'","symbol":"copy","correct":"import { copy } from 'esbuild-copy-files-plugin'"},{"note":"CommonJS destructuring required.","wrong":"const copy = require('esbuild-copy-files-plugin')","symbol":"copy","correct":"const { copy } = require('esbuild-copy-files-plugin')"},{"note":"No default export in CommonJS.","wrong":"const copy = require('esbuild-copy-files-plugin').default","symbol":"copy","correct":"import { copy } from 'esbuild-copy-files-plugin'"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst { copy } = require('esbuild-copy-files-plugin');\nesbuild.build({\n  entryPoints: ['./src/index.js'],\n  bundle: true,\n  outfile: './dist/bundle.js',\n  plugins: [\n    copy({\n      source: ['./src/index.html', './src/assets/images'],\n      target: './dist',\n      copyWithFolder: true\n    })\n  ]\n}).catch(() => process.exit(1));","lang":"javascript","description":"Shows how to configure the plugin with CJS in esbuild to copy HTML and images preserving folder structure."},"warnings":[{"fix":"Ensure source array has at least one path.","message":"Empty source array causes plugin to silently do nothing.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use copyWithFolder: true or ensure unique filenames.","message":"copyWithFolder: false may overwrite files with same name from different sources.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Manually list specific directories or files if full depth is undesirable.","message":"Recursive directory copying maintains depth; no depth limit or file filter.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Update both packages: npm install esbuild@latest esbuild-copy-files-plugin@latest","cause":"Older plugin versions require esbuild <0.14.0","error":"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."},{"fix":"Use: import { copy } from 'esbuild-copy-files-plugin' or const { copy } = require('esbuild-copy-files-plugin')","cause":"Importing default instead of named export or using require without destructuring","error":"TypeError: copy is not a function"},{"fix":"Verify source paths and ensure they exist relative to process.cwd()","cause":"Source path does not exist or is incorrect","error":"ENOENT: no such file or directory, copyfile '...' -> '...'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}