{"id":21222,"library":"esbuild-copy-static-files","title":"esbuild-copy-static-files","description":"An esbuild plugin (v0.1.0, stable) to copy static files from a source to destination directory only when files have changed (by MD5 hash). No third-party dependencies, purely uses Node.js standard library. Primarily designed to avoid unnecessary file copies during development with live-reloading tools. Differs from alternatives like `esbuild-plugin-copy` by focusing on change detection and minimal configuration.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/nickjj/esbuild-copy-static-files","tags":["javascript","esbuild","copy","static","files"],"install":[{"cmd":"npm install esbuild-copy-static-files","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-copy-static-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-copy-static-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin integration","package":"esbuild","optional":false}],"imports":[{"note":"Package uses CommonJS; no ESM exports available. Use require() or wrap in default import if using ESM.","wrong":"import copyStaticFiles from 'esbuild-copy-static-files'","symbol":"default","correct":"const copyStaticFiles = require('esbuild-copy-static-files')"},{"note":"Named import is incorrect; the module exports a single function as default.","wrong":"import { copyStaticFiles } from 'esbuild-copy-static-files'","symbol":"copyStaticFiles","correct":"import copyStaticFiles from 'esbuild-copy-static-files'"},{"note":"copyStaticFiles is a factory function, not a constructor. Do not use `new`.","wrong":"plugins: [new copyStaticFiles()]","symbol":"esbuild plugin usage","correct":"plugins: [copyStaticFiles()]"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst copyStaticFiles = require('esbuild-copy-static-files');\n\nrequire('fs').writeFileSync('./static/test.txt', 'hello');\n\nesbuild.build({\n  entryPoints: ['./app.js'],\n  outfile: './out/app.js',\n  bundle: true,\n  plugins: [\n    copyStaticFiles({\n      src: './static',\n      dest: './out',\n      filter: (src) => !src.endsWith('.bak'),\n      force: true,\n    }),\n  ],\n}).catch(() => process.exit(1));\n\n// Verify: fs.existsSync('./out/test.txt') // true","lang":"javascript","description":"Configures esbuild with the plugin to copy static files from './static' to './out', skipping '.bak' files."},"warnings":[{"fix":"Use Node.js 16.7.0 or higher. Check your Node version with `node --version`.","message":"Plugin uses Node's fs.cpSync which is only available in Node 16.7.0+.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you have many static files, consider alternative async plugins like `esbuild-plugin-copy`.","message":"The plugin copies files synchronously; this can block the event loop during large copies.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use path.basename or path.relative for filtering instead of simple string checks.","message":"The `filter` option receives absolute paths; relative comparisons may fail.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set `force: true` or `errorOnExist: false` explicitly to avoid errors.","message":"When `force: false` and destination exists, the operation throws even if `errorOnExist` is false (contrary to Node docs).","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `const copyStaticFiles = require('esbuild-copy-static-files')` or `import copyStaticFiles from 'esbuild-copy-static-files'`.","cause":"Using named import instead of default import.","error":"TypeError: copyStaticFiles is not a function"},{"fix":"Ensure `src` path exists relative to the build script. Use absolute paths or verify directory structure.","cause":"Source directory does not exist or path is incorrect.","error":"Error: ENOENT: no such file or directory, copyfile '...' -> '...'"},{"fix":"Update `filter` to exclude FIFO/pipe files: `filter: (src) => !fs.statSync(src).isFIFO()`","cause":"Filter includes a special file (FIFO/pipe) that cannot be copied.","error":"Error [ERR_FS_CP_FIFO_PIPE]: Cannot copy a FIFO or pipe"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}