{"id":19417,"library":"copy-webpack-plugin","title":"copy-webpack-plugin","description":"Copy individual files or entire directories to the webpack build output directory. Useful for static assets that are not processed by webpack loaders. Latest stable version is 14.0.0 (March 2026), requiring Node.js >= 20.9.0 and webpack ^5.1.0. Developed under the webpack organization, it supports patterns with globs, transform functions, filtering, and concurrency control. Ships TypeScript types. Replaced globby/fast-glob with tinyglobby in v13, and serialization library for security fixes in v14.","status":"active","version":"14.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/webpack/copy-webpack-plugin","tags":["javascript","webpack","plugin","transfer","move","copy","typescript"],"install":[{"cmd":"npm install copy-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add copy-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add copy-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires webpack 5 or higher","package":"webpack","optional":false}],"imports":[{"note":"CommonJS default export. ESM import (without node's module setting) will fail because package does not provide an ESM entry point.","wrong":"import CopyPlugin from 'copy-webpack-plugin';","symbol":"CopyPlugin","correct":"const CopyPlugin = require('copy-webpack-plugin');"},{"note":"Valid if your webpack config is ESM (e.g., using .mjs or type: module). However, the package only exports a single default export; named import does not work.","wrong":"","symbol":"CopyPlugin","correct":"import CopyPlugin from 'copy-webpack-plugin';"},{"note":"patterns is an array; passing from/to directly to the options object is invalid. Each pattern is an object or a string.","wrong":"new CopyPlugin({ from: 'src', to: 'dest' })","symbol":"patterns","correct":"new CopyPlugin({ patterns: [{ from: 'src', to: 'dest' }] })"},{"note":"TypeScript types ship with the package. The module has a default export only; named import will cause TS error.","wrong":"import { CopyPlugin } from 'copy-webpack-plugin';","symbol":"types (TypeScript)","correct":"import CopyPlugin from 'copy-webpack-plugin';"}],"quickstart":{"code":"const CopyPlugin = require('copy-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  mode: 'production',\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        { from: 'static', to: 'assets' },\n        { from: 'node_modules/some-lib/dist/some.min.js', to: 'lib.js' },\n        { from: '*.html', context: 'src', globOptions: { ignore: ['**/ignored/**'] } },\n      ],\n      options: { concurrency: 50 },\n    }),\n  ],\n};","lang":"javascript","description":"Basic webpack config using copy-webpack-plugin to copy static files, a single vendor library, and HTML files with glob options."},"warnings":[{"fix":"Upgrade Node.js to version 20.9.0 or higher.","message":"Minimum Node.js version increased to 20.9.0 in v14.0.0","severity":"breaking","affected_versions":">=14.0.0"},{"fix":"Review tinyglobby documentation for pattern syntax changes. Patterns that worked with globby/fast-glob might need adjustment.","message":"Switched from globby and fast-glob to tinyglobby in v13.0.0 - glob patterns may behave differently","severity":"breaking","affected_versions":">=13.0.0"},{"fix":"Upgrade Node.js to version 18.12.0 or higher, or stay on v11.x if Node 14 is required.","message":"Minimum Node.js version raised to 18.12.0 in v12.0.0","severity":"breaking","affected_versions":">=12.0.0 <13.0.0"},{"fix":"Upgrade Node.js to version 14.15.0 or higher.","message":"Minimum Node.js version increased to 14.15.0 in v11.0.0","severity":"breaking","affected_versions":">=11.0.0 <12.0.0"},{"fix":"Check the transform function's arguments in the documentation; the file path and source may be passed differently.","message":"The 'transform' function receives different arguments in v13+ (using tinyglobby) vs older versions","severity":"deprecated","affected_versions":">=13.0.0"},{"fix":"Always use forward slashes (/) in glob patterns. Use path.posix.join for absolute globs.","message":"Using backslashes in 'from' glob patterns breaks on Unix systems","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use webpack's own asset handling or write-to-disk plugins for files output by loaders/plugins.","message":"plugin does not copy files generated during build; only copies existing files from source tree","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install copy-webpack-plugin --save-dev' and ensure it's in your package.json.","cause":"Plugin is not installed, or installed as a devDependency but not available in the production environment.","error":"Error: Cannot find module 'copy-webpack-plugin'"},{"fix":"Use 'const CopyPlugin = require(\"copy-webpack-plugin\");' or 'import CopyPlugin from \"copy-webpack-plugin\";'","cause":"Using import { CopyPlugin } from 'copy-webpack-plugin' instead of default import.","error":"TypeError: CopyPlugin is not a constructor"},{"fix":"Wrap your configuration in a 'patterns' array: new CopyPlugin({ patterns: [{ from: '...', to: '...' }] })","cause":"Passing 'from' and 'to' directly to the plugin instead of inside a 'patterns' array.","error":"ValidationError: Invalid options object. CopyPlugin has been initialized using an options object that does not match the API schema."},{"fix":"Check your glob pattern and context directory. Ensure the path is relative to the context (defaults to webpack's context).","cause":"Glob pattern does not match any files, or the 'context' is incorrect.","error":"Error: No matching files found for pattern '...'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}