{"name":"copy-webpack-plugin","version":"13.0.0","keywords":["webpack","plugin","transfer","move","copy"],"author":{"name":"Len Boyette"},"license":"MIT","_id":"copy-webpack-plugin@13.0.0","maintainers":[{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"jhnns","email":"mail@johannesewald.de"}],"homepage":"https://github.com/webpack-contrib/copy-webpack-plugin","bugs":{"url":"https://github.com/webpack-contrib/copy-webpack-plugin/issues"},"dist":{"shasum":"793342576eed76fdbc7936b873eae17aa7a7d9a3","tarball":"http://registry-npm.ywwl.com/copy-webpack-plugin/download/copy-webpack-plugin-13.0.0.tgz","fileCount":8,"integrity":"sha512-FgR/h5a6hzJqATDGd9YG41SeDViH+0bkHn6WNXCi5zKAZkeESeSxLySSsFLHqLEVCh0E+rITmCf0dusXWYukeQ==","signatures":[{"sig":"MEUCIC74CYezxKKwD6HFDpil1xb2XPBr0s+U1DTIhwmwbJZcAiEA0KCM3FbLH5yucKRwR7nenY8rcmKSB3MlOfIW92S/Dhw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":74928,"size":16586,"noattachment":false,"key":"/copy-webpack-plugin/-/copy-webpack-plugin-13.0.0.tgz"},"main":"dist/index.js","types":"types/index.d.ts","engines":{"node":">= 18.12.0"},"funding":{"url":"https://opencollective.com/webpack","type":"opencollective"},"gitHead":"9c5e10a1fdace5203d675981db53cacedf8c66cf","scripts":{"fix":"npm-run-all -l fix:js fix:prettier","lint":"npm-run-all -l -p \"lint:**\"","test":"npm run test:coverage","build":"npm-run-all -p \"build:**\"","clean":"del-cli dist types","start":"npm run build -- -w","fix:js":"npm run lint:js -- --fix","lint:js":"eslint --cache .","prepare":"husky && npm run build","pretest":"npm run lint","release":"standard-version","prebuild":"npm run clean","security":"npm audit --production","test:only":"cross-env NODE_ENV=test node --experimental-vm-modules node_modules/jest/bin/jest.js","build:code":"cross-env NODE_ENV=production babel src -d dist --copy-files","commitlint":"commitlint --from=master","lint:types":"tsc --pretty --noEmit","test:watch":"npm run test:only -- --watch","build:types":"tsc --declaration --emitDeclarationOnly --outDir types --rootDir src && prettier \"types/**/*.ts\" --write","fix:prettier":"npm run lint:prettier -- --write","lint:prettier":"prettier --cache --list-different .","lint:spelling":"cspell --cache --no-must-find-files --quiet \"**/*.*\"","test:coverage":"npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage"},"_npmUser":{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},"repository":{"url":"git+https://github.com/webpack-contrib/copy-webpack-plugin.git","type":"git"},"_npmVersion":"10.9.2","description":"Copy files && directories with webpack","directories":{},"_nodeVersion":"22.13.1","dependencies":{"tinyglobby":"^0.2.12","glob-parent":"^6.0.1","schema-utils":"^4.2.0","normalize-path":"^3.0.0","serialize-javascript":"^6.0.2"},"_hasShrinkwrap":false,"devDependencies":{"del":"^6.1.1","jest":"^29.7.0","husky":"^9.1.4","memfs":"^4.11.1","cspell":"^8.15.6","eslint":"^8.57.0","del-cli":"^6.0.0","is-gzip":"^2.0.0","webpack":"^5.91.0","prettier":"^3.2.5","cross-env":"^7.0.3","@babel/cli":"^7.24.6","babel-jest":"^29.7.0","typescript":"^5.4.5","@babel/core":"^7.25.2","@types/node":"^22.13.5","file-loader":"^6.2.0","lint-staged":"^15.2.8","npm-run-all":"^4.1.5","@commitlint/cli":"^19.3.0","standard-version":"^9.3.1","@babel/preset-env":"^7.25.3","@types/glob-parent":"^5.1.3","@babel/eslint-parser":"^7.25.1","eslint-plugin-import":"^2.29.1","@types/normalize-path":"^3.0.2","eslint-config-prettier":"^9.1.0","@types/serialize-javascript":"^5.0.4","@commitlint/config-conventional":"^19.2.2","@webpack-contrib/eslint-config-webpack":"^3.0.0"},"peerDependencies":{"webpack":"^5.1.0"},"_npmOperationalInternal":{"tmp":"tmp/copy-webpack-plugin_13.0.0_1740693656009_0.3172354111772757","host":"s3://npm-registry-packages-npm-production"},"readme":"<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# copy-webpack-plugin\n\nCopies existing individual files or entire directories to the build directory.\n\n## Getting Started\n\nTo begin, you'll need to install `copy-webpack-plugin`:\n\n```console\nnpm install copy-webpack-plugin --save-dev\n```\n\nor\n\n```console\nyarn add -D copy-webpack-plugin\n```\n\nor\n\n```console\npnpm add -D copy-webpack-plugin\n```\n\nThen add the plugin to your `webpack` configuration. For example:\n\n**webpack.config.js**\n\n```js\nconst CopyPlugin = require(\"copy-webpack-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        { from: \"source\", to: \"dest\" },\n        { from: \"other\", to: \"public\" },\n      ],\n    }),\n  ],\n};\n```\n\n> [!NOTE]\n>\n> `copy-webpack-plugin` is not designed to copy files generated during the build process. Instead, it is meant to copy files that already exist in the source tree, as part of the build process.\n\n> [!NOTE]\n>\n> If you want `webpack-dev-server` to write files to the output directory during development, you can enable the [`writeToDisk`](https://github.com/webpack/webpack-dev-middleware#writetodisk) option or use the [`write-file-webpack-plugin`](https://github.com/gajus/write-file-webpack-plugin).\n\n> [!NOTE]\n>\n> You can get the original source filename from the [Asset Objects](https://webpack.js.org/api/stats/#asset-objects) in the webpack stats API.\n\n## Options\n\n- **[`patterns`](#patterns)**\n- **[`options`](#options-1)**\n\nThe plugin's usage:\n\n**webpack.config.js**\n\n```js\nconst CopyPlugin = require(\"copy-webpack-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        { from: \"source\", to: \"dest\" },\n        \"path/to/source\", // Absolute or relative path, can be files, directories or globs. See examples below.\n      ],\n      options: {\n        concurrency: 100,\n      },\n    }),\n  ],\n};\n```\n\n### `Patterns`\n\n- [`from`](#from)\n- [`to`](#to)\n- [`context`](#context)\n- [`globOptions`](#globoptions)\n- [`filter`](#filter)\n- [`toType`](#totype)\n- [`force`](#force)\n- [`priority`](#priority)\n- [`transform`](#transform)\n- [`transformAll`](#transformAll)\n- [`noErrorOnMissing`](#noerroronmissing)\n- [`info`](#info)\n\n#### `from`\n\nType:\n\n```ts\ntype from = string;\n```\n\nDefault: `undefined`\n\nGlob or path from where we copy files.\nGlobs follow the [fast-glob pattern-syntax](https://github.com/mrmlnc/fast-glob#pattern-syntax).\nNote: Globs must be a `string`.\n\n> [!WARNING]\n>\n> Don't use directly `\\\\` in `from` option if it is a `glob` (i.e `path\\to\\file.ext`) option, as backslashes are treated as regular characters on UNIX systems(not as path separators).\n> On Windows, both forward slashes and backslashes act as separators.\n> Use `/` instead, or use Node's `path` utilities to normalize paths.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        \"relative/path/to/file.ext\",\n        \"relative/path/to/dir\",\n        path.resolve(__dirname, \"src\", \"file.ext\"),\n        path.resolve(__dirname, \"src\", \"dir\"),\n        \"**/*\",\n        {\n          from: \"**/*\",\n        },\n        // If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`\n        path.posix.join(\n          path.resolve(__dirname, \"src\").replaceAll(\"\\\\\", \"/\"),\n          \"*.txt\",\n        ),\n      ],\n    }),\n  ],\n};\n```\n\n##### `For windows`\n\nIf you're using an absolute file or folder path in the `from` option on `Windows`, you can use windows path segment (`\\\\`)\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: path.resolve(__dirname, \"file.txt\"),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nHowever, when writing `glob` expressions, always use forward slashes.\nSee the [fast-glob manual](https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows) for more details.\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          // If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`\n          from: path.posix.join(\n            path.resolve(__dirname, \"fixtures\").replaceAll(\"\\\\\", \"/\"),\n            \"*.txt\",\n          ),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nThe behavior of the `context` option varies depending on whether the `from` value is a `glob`, `file` or `dir`.\nSee more [`examples`](#examples).\n\n#### `to`\n\nType:\n\n```ts\ntype to =\n  | string\n  | ((pathData: { context: string; absoluteFilename?: string }) => string);\n```\n\nDefault: `compiler.options.output`\n\n##### `string`\n\nSpecifies the output path.\n\n> [!WARNING]\n>\n> Don't use directly `\\\\` in the `to` path (i.e `path\\to\\dest`) option, as backslashes are treated as regular characters on UNIX systems(not as path separators).\n> On Windows, both forward slashes and backslashes act as separators.\n> Use `/` instead, or use Node's `path` utilities to normalize paths.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"**/*\",\n          to: \"relative/path/to/dest/\",\n        },\n        {\n          from: \"**/*\",\n          to: \"/absolute/path/to/dest/\",\n        },\n        {\n          from: \"**/*\",\n          to: \"[path][name].[contenthash][ext]\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `function`\n\nAllows to modify the writing path.\n\n> [!WARNING]\n>\n> Don't use directly `\\\\` in `to` (i.e `path\\to\\newFile`) option, as backslashes are treated as regular characters on UNIX systems(not as path separators).\n> On Windows, both forward slashes and backslashes act as separators.\n> Use `/` instead, or use Node's `path` utilities to normalize paths.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to({ context, absoluteFilename }) {\n            return \"dest/newPath/[name][ext]\";\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to({ context, absoluteFilename }) {\n            return Promise.resolve(\"dest/newPath/[name][ext]\");\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `context`\n\nType:\n\n```ts\ntype context = string;\n```\n\nDefault: `options.context|compiler.options.context`\n\nDefines the base directory used for two purposes:\n\n1. It is prepended to the `from` path.\n\n2. It is removed from the beginning of the result path(s).\n\n> [!WARNING]\n>\n> Don't use directly `\\\\` in `to` (i.e `path\\to\\newFile`) option, as backslashes are treated as regular characters on UNIX systems(not as path separators).\n> On Windows, both forward slashes and backslashes act as separators.\n> Use `/` instead, or use Node's `path` utilities to normalize paths.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.txt\",\n          to: \"dest/\",\n          context: \"app/\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\nThe `context` can be an absolute or relative path. If it's relative, then it will be converted to an absolute path based on `compiler.options.context`.\n\nYou should explicitly define `context` when `from` uses a glob pattern. Otherwise, the plugin sets it automatically based on the nature of `from`:\n\n- If `from` is a file, then `context` defaults to the file’s directory. The result path will be just the filename alone.\n\n- If `from` is a directory, `context` is set to the same directory. The result paths include the directory’s contents (including subdirectories), relative to it.\n\nThe use of `context` is illustrated by these [`examples`](#examples).\n\n#### `globOptions`\n\n> [!WARNING]\n>\n> The _onlyDirectories_ does not work because the plugin is designed to copy files, not directories alone.\n\nType:\n\n```ts\ntype globOptions = import(\"tinyglobby\").GlobOptions;\n```\n\nDefault: `undefined`\n\nAllows you to configure the glob pattern matching library used by the plugin. [See the list of supported options][glob-options]\nTo exclude files from being copied, use the [globOptions.ignore option](https://github.com/mrmlnc/fast-glob#ignore)\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"public/**/*\",\n          globOptions: {\n            dot: true,\n            gitignore: true,\n            ignore: [\"**/file.*\", \"**/ignored-directory/**\"],\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `filter`\n\nType:\n\n```ts\ntype filter = (filepath: string) => boolean;\n```\n\nDefault: `undefined`\n\n> [!NOTE]\n>\n> To ignore files by path (e.g., by extension or name), prefer using the [`globOptions.ignore`] option.\n\n**webpack.config.js**\n\n```js\nconst fs = require(\"node:fs\").promise;\n\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"public/**/*\",\n          filter: async (resourcePath) => {\n            const data = await fs.promises.readFile(resourcePath);\n            const content = data.toString();\n\n            if (content === \"my-custom-content\") {\n              return false;\n            }\n\n            return true;\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `toType`\n\nType:\n\n```ts\ntype toType = \"dir\" | \"file\" | \"template\";\n```\n\nDefault: `undefined`\n\nDetermines the type of the `to` option — whether it's a directory, file, or template.\nSometimes it is hard to say what is `to`, example `path/to/dir-with.ext`.\nIf you want to copy files in directory you should explicitly set the type to `dir`.\nIn most cases, the plugin will automatically determine the correct `type`, so you typically don't need to set this option manually.\n\n|             Name              |   Type   |   Default   | Description                                                                                                 |\n| :---------------------------: | :------: | :---------: | :---------------------------------------------------------------------------------------------------------- |\n|      **[`'dir'`](#dir)**      | `string` | `undefined` | Used `to` has no extension or ends with a `'/'`.                                                            |\n|     **[`'file'`](#file)**     | `string` | `undefined` | Used when `to` is a file path that is not a directory or template.                                          |\n| **[`'template'`](#template)** | `string` | `undefined` | Used when `to` contains [a template pattern](https://webpack.js.org/configuration/output/#template-strings) |\n\n##### `'dir'`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"path/to/file.txt\",\n          to: \"directory/with/extension.ext\",\n          toType: \"dir\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `'file'`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"path/to/file.txt\",\n          to: \"file/without/extension\",\n          toType: \"file\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `'template'`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/\",\n          to: \"dest/[name].[contenthash][ext]\",\n          toType: \"template\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `force`\n\nType:\n\n```ts\ntype force = boolean;\n```\n\nDefault: `false`\n\nOverwrites files that already exist in `compilation.assets` (typically added by other plugins or loaders).\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/**/*\",\n          to: \"dest/\",\n          force: true,\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `priority`\n\nType:\n\n```ts\ntype priority = number;\n```\n\nDefault: `0`\n\nAllows to specify the priority of copying files with the same destination name.\nFiles for patterns with higher priority will be copied later.\nTo enable overwriting, the [`force`](#force) option must be set to `true`.\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        // Copied second and will overwrite \"dir_2/file.txt\"\n        {\n          from: \"dir_1/file.txt\",\n          to: \"newfile.txt\",\n          force: true,\n          priority: 10,\n        },\n        // Copied first\n        {\n          from: \"dir_2/file.txt\",\n          to: \"newfile.txt\",\n          priority: 5,\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `transform`\n\nType:\n\n```ts\ntype transform =\n  | {\n      transformer: (input: string, absoluteFilename: string) => string | Buffer;\n      cache?: boolean | TransformerCacheObject | undefined;\n    }\n  | ((input: string, absoluteFilename: string) => string | Buffer);\n```\n\nDefault: `undefined`\n\nAllows you to modify the contents of a file before it is written to the output directory.\n\n##### `function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          // The `content` argument is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`\n          // The `absoluteFrom` argument is a `String`, it is absolute path from where the file is being copied\n          transform(content, absoluteFrom) {\n            return optimize(content);\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `object`\n\n|               Name                |   Default   | Description                                                                                                                                |\n| :-------------------------------: | :---------: | :----------------------------------------------------------------------------------------------------------------------------------------- |\n| **[`transformer`](#transformer)** | `undefined` | Allows you to modify the contents of the file.                                                                                             |\n|       **[`cache`](#cache)**       |   `false`   | Enables caching for `transform`. You can use `transform: { cache: { key: 'my-cache-key' } }` to manually invalidate the cache when needed. |\n\n###### `transformer`\n\nType:\n\n```ts\ntype transformer = (input: string, absoluteFilename: string) => string;\n```\n\nDefault: `undefined`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          // The `content` argument is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`\n          // The `absoluteFrom` argument is a `String`, it is absolute path from where the file is being copied\n          transform: {\n            transformer(content, absoluteFrom) {\n              return optimize(content);\n            },\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          transform: {\n            transformer(content, path) {\n              return Promise.resolve(optimize(content));\n            },\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n###### `cache`\n\nType:\n\n```ts\ntype cache =\n  | boolean\n  | {\n      keys: Record<string, any>;\n    }\n  | {\n      keys: (\n        defaultCacheKeys: Record<string, any>,\n        absoluteFilename: string,\n      ) => Promise<Record<string, any>>;\n    }\n  | undefined;\n```\n\nDefault: `false`\n\n**webpack.config.js**\n\nEnable or disable caching and configure its behavior.\nBy default, the cache directory is located at: `node_modules/.cache/copy-webpack-plugin`.\n\n###### `boolean`\n\nEnables/Disable `transform` caching.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          transform: {\n            transformer(content, path) {\n              return optimize(content);\n            },\n            cache: true,\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `object`\n\nEnables `transform` caching and setup invalidation keys.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          transform: {\n            transformer(content, path) {\n              return optimize(content);\n            },\n            cache: {\n              keys: {\n                // May be useful for invalidating cache based on external values\n                // For example, you can invalid cache based on `process.version` - { node: process.version }\n                key: \"value\",\n              },\n            },\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\nYou can setup invalidation keys using a function.\n\nSimple function:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          transform: {\n            transformer(content, path) {\n              return optimize(content);\n            },\n            cache: {\n              keys: (defaultCacheKeys, absoluteFrom) => {\n                const keys = getCustomCacheInvalidationKeysSync();\n\n                return {\n                  ...defaultCacheKeys,\n                  keys,\n                };\n              },\n            },\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\nAsync function:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/*.png\",\n          to: \"dest/\",\n          transform: {\n            transformer(content, path) {\n              return optimize(content);\n            },\n            cache: {\n              keys: async (defaultCacheKeys, absoluteFrom) => {\n                const keys = await getCustomCacheInvalidationKeysAsync();\n\n                return {\n                  ...defaultCacheKeys,\n                  keys,\n                };\n              },\n            },\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `transformAll`\n\nType:\n\n```ts\ntype transformAll = (\n  data: {\n    data: Buffer;\n    sourceFilename: string;\n    absoluteFilename: string;\n  }[],\n) => string[];\n```\n\nDefault: `undefined`\n\nAllows you to modify the contents of multiple files and save the combined result into a single file.\n\n> [!NOTE]\n>\n> The `to` option must be specified and point to a file. Only the `[contenthash]` and `[fullhash]` template strings are allowed in the filename.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/**/*.txt\",\n          to: \"dest/file.txt\",\n          // The `assets` argument is an array of assets matched by the pattern `from` (\"src/**/*.txt\")\n          transformAll(assets) {\n            const result = assets.reduce((accumulator, asset) => {\n              // The asset content can be obtained from `asset.source` using `source` method.\n              // The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`\n              const content = asset.data;\n\n              accumulator = `${accumulator}${content}\\n`;\n              return accumulator;\n            }, \"\");\n\n            return result;\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n### `noErrorOnMissing`\n\nType:\n\n```ts\ntype noErrorOnMissing = boolean;\n```\n\nDefault: `false`\n\nDoesn't generate an error if file(s) are missing.\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: path.resolve(__dirname, \"missing-file.txt\"),\n          noErrorOnMissing: true,\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### `info`\n\nType:\n\n```ts\ntype info =\n  | Record<string, any>\n  | ((item: {\n      absoluteFilename: string;\n      sourceFilename: string;\n      filename: string;\n      toType: ToType;\n    }) => Record<string, any>);\n```\n\nDefault: `undefined`\n\nAllows to add assets info.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        \"relative/path/to/file.ext\",\n        {\n          from: \"**/*\",\n          // Terser skip this file for minification\n          info: { minimized: true },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        \"relative/path/to/file.ext\",\n        {\n          from: \"**/*\",\n          // Terser skip this file for minimization\n          info: (file) => ({ minimized: true }),\n        },\n      ],\n    }),\n  ],\n};\n```\n\n### Options\n\n- [`concurrency`](#concurrency)\n\n#### `concurrency`\n\ntype:\n\n```ts\ntype concurrency = number;\n```\n\nDefault: `100`\n\nLimits the number of simultaneous requests to fs.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [...patterns],\n      options: { concurrency: 50 },\n    }),\n  ],\n};\n```\n\n### Examples\n\n#### Different variants of `from` (`glob`, `file` or `dir`).\n\nConsider the following file structure:\n\n```\nsrc/directory-nested/deep-nested/deepnested-file.txt\nsrc/directory-nested/nested-file.txt\n```\n\n##### From is a Glob\n\nEverything that you specify in `from` will be included in the result:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/directory-nested/**/*\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\nsrc/directory-nested/deep-nested/deepnested-file.txt,\nsrc/directory-nested/nested-file.txt\n```\n\nIf you don't want the result paths to start with `src/directory-nested/`, then you should move `src/directory-nested/` to `context`, such that only the glob pattern `**/*` remains in `from`:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"**/*\",\n          context: path.resolve(__dirname, \"src\", \"directory-nested\"),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\ndeep-nested/deepnested-file.txt,\nnested-file.txt\n```\n\n##### From is a Dir\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: path.resolve(__dirname, \"src\", \"directory-nested\"),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\ndeep-nested/deepnested-file.txt,\nnested-file.txt\n```\n\nTechnically, this is equivalent to using `**/*` with a predefined context set to the specified directory\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"**/*\",\n          context: path.resolve(__dirname, \"src\", \"directory-nested\"),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\ndeep-nested/deepnested-file.txt,\nnested-file.txt\n```\n\n##### From is a File\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: path.resolve(\n            __dirname,\n            \"src\",\n            \"directory-nested\",\n            \"nested-file.txt\",\n          ),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\nnested-file.txt\n```\n\nTechnically, this is a filename with a predefined context equal to the file's directory `path.dirname(pathToFile)`.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"nested-file.txt\",\n          context: path.resolve(__dirname, \"src\", \"directory-nested\"),\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\nnested-file.txt\n```\n\n#### Ignoring files\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: path.posix.join(\n            path.resolve(__dirname, \"src\").replaceAll(\"\\\\\", \"/\"),\n            \"**/*\",\n          ),\n          globOptions: {\n            ignore: [\n              // Ignore all `txt` files\n              \"**/*.txt\",\n              // Ignore all files in all subdirectories\n              \"**/subdir/**\",\n            ],\n          },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n#### Flatten copy\n\nRemoves all directory references and copies only file names.\n\n> [!WARNING]\n>\n> If files have the same name, the result is non-deterministic.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: \"src/**/*\",\n          to: \"[name][ext]\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\nfile-1.txt\nfile-2.txt\nnested-file.txt\n```\n\n#### Copy in new directory\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          // When copying files starting with a dot, must specify the toType option\n          // toType: \"file\",\n          to({ context, absoluteFilename }) {\n            return `newdirectory/${path.relative(context, absoluteFilename)}`;\n          },\n          from: \"directory\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\nResult:\n\n```txt\n\"newdirectory/file-1.txt\",\n\"newdirectory/nestedfile.txt\",\n\"newdirectory/nested/deep-nested/deepnested.txt\",\n\"newdirectory/nested/nestedfile.txt\",\n```\n\n#### Skip running JavaScript files through a minimizer\n\nUseful if you need to simply copy `*.js` files to destination \"as is\" without evaluating and minimizing them using Terser.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        \"relative/path/to/file.ext\",\n        {\n          from: \"**/*\",\n          // Terser skip this file for minimization\n          info: { minimized: true },\n        },\n      ],\n    }),\n  ],\n};\n```\n\n##### `yarn workspaces` and `monorepos`\n\nWhen using `yarn workspaces` or` monorepos`, relative copy paths from `node_modules` can be broken due to the way packages are hoisting.\nTo avoid this, you should explicitly specify where to copy the files from; by using `require.resolve`.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  plugins: [\n    new CopyPlugin({\n      patterns: [\n        {\n          from: `${path.dirname(\n            require.resolve(`${moduleName}/package.json`),\n          )}/target`,\n          to: \"target\",\n        },\n      ],\n    }),\n  ],\n};\n```\n\n## Contributing\n\nWe welcome all contributions!\n\nIf you are new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.\n\n[CONTRIBUTING](https://github.com/webpack/copy-webpack-plugin?tab=contributing-ov-file#contributing)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/copy-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/copy-webpack-plugin\n[node]: https://img.shields.io/node/v/copy-webpack-plugin.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/copy-webpack-plugin/workflows/copy-webpack-plugin/badge.svg\n[tests-url]: https://github.com/webpack/copy-webpack-plugin/actions\n[cover]: https://codecov.io/gh/webpack/copy-webpack-plugin/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/copy-webpack-plugin\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=copy-webpack-plugin\n[size-url]: https://packagephobia.now.sh/result?p=copy-webpack-plugin\n[glob-options]: https://github.com/SuperchupuDev/tinyglobby#options\n","publish_time":1740693656211,"_cnpm_publish_time":1740693656211,"dist-tags":{"latest":"14.0.0","version-5":"5.1.2","version-6":"6.4.1"}}