copy-webpack
raw JSON → 6.0.0 verified Sat Apr 25 auth: no javascript
A simplified alternative to copy-webpack-plugin for copying files and directories during webpack builds. Current stable version is 6.0.0, released with node >=24 and webpack ^5.105.0 peer dependencies. Key differentiators: vastly simplified API (single string for a glob pattern, no nested `patterns` array), minimal configuration, and ESM-only exports. Replaces the verbose copy-webpack-plugin with a concise one-liner for common use cases, while still supporting advanced options via an array of objects. Active development under the best-shot organization.
Common errors
error TypeError: CopyWebpack is not a constructor ↓
cause Importing default instead of named export
fix
Correct import: import { CopyWebpack } from 'copy-webpack'
error Module not found: Error: Can't resolve 'copy-webpack' ↓
cause Package not installed or peer dependency webpack missing
fix
Run 'npm install copy-webpack webpack --save-dev'
error ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './package.json' is not defined ↓
cause Trying to import from subpath that is not exported
fix
Only import from 'copy-webpack' directly; no subpath imports are supported.
Warnings
breaking Version 6.0.0 drops support for Node versions below 24 and pnpm <10. ↓
fix Upgrade Node.js to >=24 and pnpm to >=10 (or use an alternative package).
deprecated The original copy-webpack-plugin pattern with nested `patterns` array is deprecated. ↓
fix Use the simplified `new CopyWebpack(from)` or `new CopyWebpack([...])` API.
gotcha Package is ESM-only; CommonJS require with `require('copy-webpack')` will fail. ↓
fix Use dynamic import: `const { CopyWebpack } = await import('copy-webpack')`.
gotcha Plugin does not validate options at instantiation time; misconfigurations may cause silent failures. ↓
fix Test with a sample file to ensure the glob pattern matches expected files.
Install
npm install copy-webpack yarn add copy-webpack pnpm add copy-webpack Imports
- CopyWebpack wrong
import CopyWebpack from 'copy-webpack'correctimport { CopyWebpack } from 'copy-webpack' - CopyWebpack (via require in CJS) wrong
const CopyWebpack = require('copy-webpack')correctconst { CopyWebpack } = require('copy-webpack') - TypeScript type (if any) wrong
import { CopyWebpack } from 'copy-webpack'correctimport type { CopyWebpack } from 'copy-webpack'
Quickstart
// webpack.config.mjs
import { CopyWebpack } from 'copy-webpack';
export default {
plugins: [
new CopyWebpack('static')
]
};