{"id":25324,"library":"esbuild-plugin-copy-file","title":"esbuild-plugin-copy-file","description":"An esbuild plugin for copying files asynchronously and in parallel before and after bundling. Current stable version is 0.0.2. Released sporadically. It offers a simple configuration object mapping target to source paths for both pre- and post-bundle copies. Differentiates from other copy plugins by its minimal API and concurrency support.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/ozanozbek/esbuild-plugin-copy-file","tags":["javascript","esbuild","plugin","file","copy"],"install":[{"cmd":"npm install esbuild-plugin-copy-file","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-copy-file","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-copy-file","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used for file copy operations with async support","package":"fs-extra","optional":true}],"imports":[{"note":"The package exports a single default function; named destructuring will result in undefined.","wrong":"import { copyFilePlugin } from 'esbuild-plugin-copy-file';","symbol":"default (no named exports)","correct":"import copyFilePlugin from 'esbuild-plugin-copy-file';"},{"note":"Because the default export is transpiled to module.exports.default, direct require() returns an object with default property.","wrong":"const copyFilePlugin = require('esbuild-plugin-copy-file');","symbol":"CommonJS require","correct":"const copyFilePlugin = require('esbuild-plugin-copy-file').default;"},{"note":"The before and after options expect an object mapping target path to source path, not source to destination. The key is the target (where to copy to) and the value is the source (where to copy from). This is reversed from many other copy utilities.","wrong":"const options = { before: { src: 'src.png', dest: 'dest.png' } };","symbol":"Configuration object","correct":"import copyFilePlugin from 'esbuild-plugin-copy-file';\nconst options = { before: { 'src.png': 'dest.png' }, after: { 'report.json': 'out/report.json' } };"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport copyFilePlugin from 'esbuild-plugin-copy-file';\n\nawait esbuild.build({\n  entryPoints: ['./src/index.js'],\n  outdir: './dist',\n  bundle: true,\n  plugins: [\n    copyFilePlugin({\n      before: {\n        './dist/manifest.json': './src/manifest.json'\n      },\n      after: {\n        './dist/report.json': './build-info/report.json'\n      }\n    })\n  ]\n});\nconsole.log('Build complete');","lang":"javascript","description":"Shows how to use esbuild-plugin-copy-file to copy a manifest file before bundling and a report file after bundling."},"warnings":[{"fix":"Use syntax { 'targetPath': 'sourcePath' } instead of { 'sourcePath': 'targetPath' }.","message":"The before and after options map target to source, not source to target. Confusing API design.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use async/await at the build level if necessary.","message":"The plugin uses synchronous fs-extra internally? (Not confirmed, but concurrency may be misleading). Check implementation before relying on parallel behavior.","severity":"deprecated","affected_versions":"0.0.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change `import { copyFilePlugin }` to `import copyFilePlugin`.","cause":"Using named import instead of default import.","error":"TypeError: copyFilePlugin is not a function"},{"fix":"Ensure source file exists and paths are relative to the project root or use absolute paths.","cause":"Provided source path does not exist or relative path resolved incorrectly.","error":"Error: ENOENT: no such file or directory, copyfile 'source.png' -> 'dest.png'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}