Detalhes do pacote

copy-webpack-plugin

webpack-contrib39.8mMIT13.0.1

Copy files && directories with webpack

webpack, plugin, transfer, move

readme (leia-me)

npm node tests cover discussion size

copy-webpack-plugin

Copies existing individual files or entire directories to the build directory.

Getting Started

To begin, you'll need to install copy-webpack-plugin:

npm install copy-webpack-plugin --save-dev

or

yarn add -D copy-webpack-plugin

or

pnpm add -D copy-webpack-plugin

Then add the plugin to your webpack configuration. For example:

webpack.config.js

const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: "source", to: "dest" },
        { from: "other", to: "public" },
      ],
    }),
  ],
};

[!NOTE]

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.

[!NOTE]

If you want webpack-dev-server to write files to the output directory during development, you can enable the writeToDisk option or use the write-file-webpack-plugin.

[!NOTE]

You can get the original source filename from the Asset Objects in the webpack stats API.

Options

The plugin's usage:

webpack.config.js

const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: "source", to: "dest" },
        "path/to/source", // Absolute or relative path, can be files, directories or globs. See examples below.
      ],
      options: {
        concurrency: 100,
      },
    }),
  ],
};

Patterns

from

Type:

type from = string;

Default: undefined

Glob or path from where we copy files. Globs follow the fast-glob pattern-syntax. Note: Globs must be a string.

[!WARNING]

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). On Windows, both forward slashes and backslashes act as separators. Use / instead, or use Node's path utilities to normalize paths.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        "relative/path/to/file.ext",
        "relative/path/to/dir",
        path.resolve(__dirname, "src", "file.ext"),
        path.resolve(__dirname, "src", "dir"),
        "**/*",
        {
          from: "**/*",
        },
        // If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`
        path.posix.join(
          path.resolve(__dirname, "src").replaceAll("\\", "/"),
          "*.txt",
        ),
      ],
    }),
  ],
};
For windows

If you're using an absolute file or folder path in the from option on Windows, you can use windows path segment (\\)

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: path.resolve(__dirname, "file.txt"),
        },
      ],
    }),
  ],
};

However, when writing glob expressions, always use forward slashes. See the fast-glob manual for more details.

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          // If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`
          from: path.posix.join(
            path.resolve(__dirname, "fixtures").replaceAll("\\", "/"),
            "*.txt",
          ),
        },
      ],
    }),
  ],
};

The behavior of the context option varies depending on whether the from value is a glob, file or dir. See more examples.

to

Type:

type to =
  | string
  | ((pathData: { context: string; absoluteFilename?: string }) => string);

Default: compiler.options.output

string

Specifies the output path.

[!WARNING]

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). On Windows, both forward slashes and backslashes act as separators. Use / instead, or use Node's path utilities to normalize paths.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "**/*",
          to: "relative/path/to/dest/",
        },
        {
          from: "**/*",
          to: "/absolute/path/to/dest/",
        },
        {
          from: "**/*",
          to: "[path][name].[contenthash][ext]",
        },
      ],
    }),
  ],
};
function

Allows to modify the writing path.

[!WARNING]

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). On Windows, both forward slashes and backslashes act as separators. Use / instead, or use Node's path utilities to normalize paths.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to({ context, absoluteFilename }) {
            return "dest/newPath/[name][ext]";
          },
        },
      ],
    }),
  ],
};

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to({ context, absoluteFilename }) {
            return Promise.resolve("dest/newPath/[name][ext]");
          },
        },
      ],
    }),
  ],
};

context

Type:

type context = string;

Default: options.context|compiler.options.context

Defines the base directory used for two purposes:

  1. It is prepended to the from path.

  2. It is removed from the beginning of the result path(s).

[!WARNING]

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). On Windows, both forward slashes and backslashes act as separators. Use / instead, or use Node's path utilities to normalize paths.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.txt",
          to: "dest/",
          context: "app/",
        },
      ],
    }),
  ],
};

The 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.

You should explicitly define context when from uses a glob pattern. Otherwise, the plugin sets it automatically based on the nature of from:

  • If from is a file, then context defaults to the file’s directory. The result path will be just the filename alone.

  • 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.

The use of context is illustrated by these examples.

globOptions

[!WARNING]

The onlyDirectories does not work because the plugin is designed to copy files, not directories alone.

Type:

type globOptions = import("tinyglobby").GlobOptions;

Default: undefined

Allows you to configure the glob pattern matching library used by the plugin. See the list of supported options To exclude files from being copied, use the globOptions.ignore option

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "public/**/*",
          globOptions: {
            dot: true,
            gitignore: true,
            ignore: ["**/file.*", "**/ignored-directory/**"],
          },
        },
      ],
    }),
  ],
};

filter

Type:

type filter = (filepath: string) => boolean;

Default: undefined

[!NOTE]

To ignore files by path (e.g., by extension or name), prefer using the [globOptions.ignore] option.

webpack.config.js

const fs = require("node:fs").promise;

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "public/**/*",
          filter: async (resourcePath) => {
            const data = await fs.promises.readFile(resourcePath);
            const content = data.toString();

            if (content === "my-custom-content") {
              return false;
            }

            return true;
          },
        },
      ],
    }),
  ],
};

toType

Type:

type toType = "dir" | "file" | "template";

Default: undefined

Determines the type of the to option — whether it's a directory, file, or template. Sometimes it is hard to say what is to, example path/to/dir-with.ext. If you want to copy files in directory you should explicitly set the type to dir. In most cases, the plugin will automatically determine the correct type, so you typically don't need to set this option manually.

Name Type Default Description
'dir' string undefined Used to has no extension or ends with a '/'.
'file' string undefined Used when to is a file path that is not a directory or template.
'template' string undefined Used when to contains a template pattern
'dir'

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "path/to/file.txt",
          to: "directory/with/extension.ext",
          toType: "dir",
        },
      ],
    }),
  ],
};
'file'

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "path/to/file.txt",
          to: "file/without/extension",
          toType: "file",
        },
      ],
    }),
  ],
};
'template'

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/",
          to: "dest/[name].[contenthash][ext]",
          toType: "template",
        },
      ],
    }),
  ],
};

force

Type:

type force = boolean;

Default: false

Overwrites files that already exist in compilation.assets (typically added by other plugins or loaders).

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/**/*",
          to: "dest/",
          force: true,
        },
      ],
    }),
  ],
};

priority

Type:

type priority = number;

Default: 0

Allows to specify the priority of copying files with the same destination name. Files for patterns with higher priority will be copied later. To enable overwriting, the force option must be set to true. webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        // Copied second and will overwrite "dir_2/file.txt"
        {
          from: "dir_1/file.txt",
          to: "newfile.txt",
          force: true,
          priority: 10,
        },
        // Copied first
        {
          from: "dir_2/file.txt",
          to: "newfile.txt",
          priority: 5,
        },
      ],
    }),
  ],
};

transform

Type:

type transform =
  | {
      transformer: (input: string, absoluteFilename: string) => string | Buffer;
      cache?: boolean | TransformerCacheObject | undefined;
    }
  | ((input: string, absoluteFilename: string) => string | Buffer);

Default: undefined

Allows you to modify the contents of a file before it is written to the output directory.

function

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          // 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()`
          // The `absoluteFrom` argument is a `String`, it is absolute path from where the file is being copied
          transform(content, absoluteFrom) {
            return optimize(content);
          },
        },
      ],
    }),
  ],
};
object
Name Default Description
transformer undefined Allows you to modify the contents of the file.
cache false Enables caching for transform. You can use transform: { cache: { key: 'my-cache-key' } } to manually invalidate the cache when needed.
transformer

Type:

type transformer = (input: string, absoluteFilename: string) => string;

Default: undefined

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          // 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()`
          // The `absoluteFrom` argument is a `String`, it is absolute path from where the file is being copied
          transform: {
            transformer(content, absoluteFrom) {
              return optimize(content);
            },
          },
        },
      ],
    }),
  ],
};

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          transform: {
            transformer(content, path) {
              return Promise.resolve(optimize(content));
            },
          },
        },
      ],
    }),
  ],
};
cache

Type:

type cache =
  | boolean
  | {
      keys: Record<string, any>;
    }
  | {
      keys: (
        defaultCacheKeys: Record<string, any>,
        absoluteFilename: string,
      ) => Promise<Record<string, any>>;
    }
  | undefined;

Default: false

webpack.config.js

Enable or disable caching and configure its behavior. By default, the cache directory is located at: node_modules/.cache/copy-webpack-plugin.

boolean

Enables/Disable transform caching.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          transform: {
            transformer(content, path) {
              return optimize(content);
            },
            cache: true,
          },
        },
      ],
    }),
  ],
};
object

Enables transform caching and setup invalidation keys.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          transform: {
            transformer(content, path) {
              return optimize(content);
            },
            cache: {
              keys: {
                // May be useful for invalidating cache based on external values
                // For example, you can invalid cache based on `process.version` - { node: process.version }
                key: "value",
              },
            },
          },
        },
      ],
    }),
  ],
};

You can setup invalidation keys using a function.

Simple function:

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          transform: {
            transformer(content, path) {
              return optimize(content);
            },
            cache: {
              keys: (defaultCacheKeys, absoluteFrom) => {
                const keys = getCustomCacheInvalidationKeysSync();

                return {
                  ...defaultCacheKeys,
                  keys,
                };
              },
            },
          },
        },
      ],
    }),
  ],
};

Async function:

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/*.png",
          to: "dest/",
          transform: {
            transformer(content, path) {
              return optimize(content);
            },
            cache: {
              keys: async (defaultCacheKeys, absoluteFrom) => {
                const keys = await getCustomCacheInvalidationKeysAsync();

                return {
                  ...defaultCacheKeys,
                  keys,
                };
              },
            },
          },
        },
      ],
    }),
  ],
};

transformAll

Type:

type transformAll = (
  data: {
    data: Buffer;
    sourceFilename: string;
    absoluteFilename: string;
  }[],
) => string[];

Default: undefined

Allows you to modify the contents of multiple files and save the combined result into a single file.

[!NOTE]

The to option must be specified and point to a file. Only the [contenthash] and [fullhash] template strings are allowed in the filename.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/**/*.txt",
          to: "dest/file.txt",
          // The `assets` argument is an array of assets matched by the pattern `from` ("src/**/*.txt")
          transformAll(assets) {
            const result = assets.reduce((accumulator, asset) => {
              // The asset content can be obtained from `asset.source` using `source` method.
              // 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()`
              const content = asset.data;

              accumulator = `${accumulator}${content}\n`;
              return accumulator;
            }, "");

            return result;
          },
        },
      ],
    }),
  ],
};

noErrorOnMissing

Type:

type noErrorOnMissing = boolean;

Default: false

Doesn't generate an error if file(s) are missing.

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: path.resolve(__dirname, "missing-file.txt"),
          noErrorOnMissing: true,
        },
      ],
    }),
  ],
};

info

Type:

type info =
  | Record<string, any>
  | ((item: {
      absoluteFilename: string;
      sourceFilename: string;
      filename: string;
      toType: ToType;
    }) => Record<string, any>);

Default: undefined

Allows to add assets info.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        "relative/path/to/file.ext",
        {
          from: "**/*",
          // Terser skip this file for minification
          info: { minimized: true },
        },
      ],
    }),
  ],
};

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        "relative/path/to/file.ext",
        {
          from: "**/*",
          // Terser skip this file for minimization
          info: (file) => ({ minimized: true }),
        },
      ],
    }),
  ],
};

Options

concurrency

type:

type concurrency = number;

Default: 100

Limits the number of simultaneous requests to fs.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [...patterns],
      options: { concurrency: 50 },
    }),
  ],
};

Examples

Different variants of from (glob, file or dir).

Consider the following file structure:

src/directory-nested/deep-nested/deepnested-file.txt
src/directory-nested/nested-file.txt
From is a Glob

Everything that you specify in from will be included in the result:

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/directory-nested/**/*",
        },
      ],
    }),
  ],
};

Result:

src/directory-nested/deep-nested/deepnested-file.txt,
src/directory-nested/nested-file.txt

If 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:

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "**/*",
          context: path.resolve(__dirname, "src", "directory-nested"),
        },
      ],
    }),
  ],
};

Result:

deep-nested/deepnested-file.txt,
nested-file.txt
From is a Dir

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: path.resolve(__dirname, "src", "directory-nested"),
        },
      ],
    }),
  ],
};

Result:

deep-nested/deepnested-file.txt,
nested-file.txt

Technically, this is equivalent to using **/* with a predefined context set to the specified directory

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "**/*",
          context: path.resolve(__dirname, "src", "directory-nested"),
        },
      ],
    }),
  ],
};

Result:

deep-nested/deepnested-file.txt,
nested-file.txt
From is a File
module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: path.resolve(
            __dirname,
            "src",
            "directory-nested",
            "nested-file.txt",
          ),
        },
      ],
    }),
  ],
};

Result:

nested-file.txt

Technically, this is a filename with a predefined context equal to the file's directory path.dirname(pathToFile).

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "nested-file.txt",
          context: path.resolve(__dirname, "src", "directory-nested"),
        },
      ],
    }),
  ],
};

Result:

nested-file.txt

Ignoring files

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: path.posix.join(
            path.resolve(__dirname, "src").replaceAll("\\", "/"),
            "**/*",
          ),
          globOptions: {
            ignore: [
              // Ignore all `txt` files
              "**/*.txt",
              // Ignore all files in all subdirectories
              "**/subdir/**",
            ],
          },
        },
      ],
    }),
  ],
};

Flatten copy

Removes all directory references and copies only file names.

[!WARNING]

If files have the same name, the result is non-deterministic.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "src/**/*",
          to: "[name][ext]",
        },
      ],
    }),
  ],
};

Result:

file-1.txt
file-2.txt
nested-file.txt

Copy in new directory

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          // When copying files starting with a dot, must specify the toType option
          // toType: "file",
          to({ context, absoluteFilename }) {
            return `newdirectory/${path.relative(context, absoluteFilename)}`;
          },
          from: "directory",
        },
      ],
    }),
  ],
};

Result:

"newdirectory/file-1.txt",
"newdirectory/nestedfile.txt",
"newdirectory/nested/deep-nested/deepnested.txt",
"newdirectory/nested/nestedfile.txt",

Skip running JavaScript files through a minimizer

Useful if you need to simply copy *.js files to destination "as is" without evaluating and minimizing them using Terser.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        "relative/path/to/file.ext",
        {
          from: "**/*",
          // Terser skip this file for minimization
          info: { minimized: true },
        },
      ],
    }),
  ],
};
yarn workspaces and monorepos

When using yarn workspaces ormonorepos, relative copy paths from node_modules can be broken due to the way packages are hoisting. To avoid this, you should explicitly specify where to copy the files from; by using require.resolve.

webpack.config.js

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: `${path.dirname(
            require.resolve(`${moduleName}/package.json`),
          )}/target`,
          to: "target",
        },
      ],
    }),
  ],
};

Contributing

We welcome all contributions!

If you are new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.

CONTRIBUTING

License

MIT

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

13.0.1 (2025-08-12)

Bug Fixes

13.0.0 (2025-02-27)

⚠ BREAKING CHANGES

  • switch from globby and fast-glob to tinyglobby (#795) (19fd937)

For more information please visit tinyglobby.

The breaking change only affects the developer who used these options - gitignore and ignoreFiles in the globOptions option.

Please migrate to the ignore option.

Bug Fixes

  • concurrency option is limited to files now (#796) (d42469c)
  • the order of patterns provided by the developer is respected

12.0.2 (2024-01-17)

Bug Fixes

12.0.1 (2024-01-11)

Bug Fixes

12.0.0 (2024-01-10)

⚠ BREAKING CHANGES

  • update globby to 14.0.0
  • minimum supported Node.js version is 18.12.0 (#759) (a5b7d06)

11.0.0 (2022-05-17)

⚠ BREAKING CHANGES

  • minimum supported Node.js version is 14.15.0

build

10.2.4 (2022-01-31)

Bug Fixes

10.2.3 (2022-01-29)

Bug Fixes

10.2.2 (2022-01-28)

Bug Fixes

10.2.1 (2022-01-20)

Bug Fixes

10.2.0 (2021-12-16)

Features

  • removed cjs wrapper and generated types in commonjs format (export = and namespaces used in types), now you can directly use exported types (#654) (5901006)

10.1.0 (2021-12-10)

Features

Bug Fixes

10.0.0 (2021-11-17)

⚠ BREAKING CHANGES

  • minimum supported Node.js version is 12.20.0
  • update globby to 12.0.2 version

9.1.0 (2021-11-11)

Features

  • output helpful descriptions and links on errors (#625) (396bed6)

Bug Fixes

  • compatibility with Node.js 17 (20af0c7)

9.0.1 (2021-06-25)

Chore

  • update serialize-javascript

9.0.0 (2021-05-21)

⚠ BREAKING CHANGES

  • minimum supported Node.js version is 12.13.0

8.1.1 (2021-04-06)

Bug Fixes

8.1.0 (2021-03-22)

Features

8.0.0 (2021-03-04)

⚠ BREAKING CHANGES

  • logic for some placeholders was changed:
    • [hash] and [fullhash] works as in webpack (i.e. it is hash of build, not content hash of file), to migrate change [name].[hash].[ext] to [name].[contenthash][ext]
    • [ext] doesn't require . (dot) before, i.e. change [name].[ext] to [name][ext]
    • [<hashType>:contenthash:<digestType>:<length>] and [<hashType>:hash:<digestType>:<length>] is not supported anymore, you can use output.hashDigest, output.hashDigestLength and output.hashFunction options to setup it
    • [N] was removed in favor of using the to option as a function
    • [folder] was removed
    • [emoji] was removed

Features

7.0.0 (2020-12-10)

⚠ BREAKING CHANGES

  • minimum supported webpack version is 5
  • the flatten option was removed in favor [name].[ext] value for the to option,
  • the transformPath option was removed in favor Function type of the to option, look at examples
  • the cacheTransform option was removed in favor Object type of the transform option, look at examples
  • migration on the compilation.hooks.processAssets hook
  • empty filtered paths throw an error, you can disable this behaviour using the noErrorOnMissing option

6.4.0 (2020-12-07)

Features

6.3.2 (2020-11-19)

Bug Fixes

6.3.1 (2020-11-13)

Bug Fixes

6.3.0 (2020-11-03)

Features

  • added the sourceFilename info (original source filename) to assets info (#542) (db2e3bf)
  • persistent cache between compilations (webpack@5 only) (#541) (c892451)

6.2.1 (2020-10-09)

Chore

  • update schema-utils

6.2.0 (2020-10-02)

Features

  • use webpack input filesystem (only webpack@5) (#531) (6f2f455)

6.1.1 (2020-09-18)

Chore

  • updated serialize-javascript

6.1.0 (2020-08-31)

Features

  • added filter option (#524) (1496f85)
  • added the copied flag to asset info (09b1dc9)
  • added the immutable flag to asset info with hash in name (#525) (a1989d5)
  • webpack@5: improve stats output for copied files

6.0.4 (2020-08-29)

Bug Fixes

6.0.3 (2020-06-30)

Bug Fixes

  • do not execute on a child compiler (42f27c7)

6.0.2 (2020-06-03)

Bug Fixes

  • security problem
  • compatibility with 10.13 version of Node.js

6.0.1 (2020-05-16)

Bug Fixes

  • concurrency writing assets (#484) (bfc712d)
  • escaping special characters in the context option (0e62695)

6.0.0 (2020-05-15)

⚠ BREAKING CHANGES

  • minimum supported Node.js version is 10.13,
  • the plugin now accepts an object, you should change new CopyPlugin(patterns, options) to new CopyPlugin({ patterns, options })
  • migrate on compilation.additionalAssets hook
  • the ignore option (which accepted micromatch syntax) was removed in favor globOptions.ignore (which accepts fast-glob pattern-syntax)
  • the test option was removed in favor the transformPath option
  • the cache option was renamed to the cacheTransform option, cacheTransform option should have only directory and keys properties when it is an object
  • global context and ignore options were removed in favor patten.context and pattern.globOptions.ignore options
  • the missing file error is now an error, before it was a warning
  • the from option now can only be a string, if you use { from: { glob: 'directory/**', dot: false } } changed it to { from: 'directory/**', globOptions: { dot: false } }
  • the copyUnmodified was removed without replacements
  • the 2 version of webpack-dev-server is not supported anymore
  • the logLevel was removed in favor the infrastructureLogging.level option, please read the documentation

Features

  • implement the concurrency option (#466) (c176d7d)
  • implement the directory option for the cacheTransform option (29254e3)
  • implement the noErrorOnMissing option (#475) (e3803ce)
  • migrate on webpack built-in logger (#446) (5af02bc)

Bug Fixes

5.1.1 (2019-12-12)

Bug Fixes

5.1.0 (2019-12-09)

Features

Bug Fixes

  • better to determine when glob is used (4826e56)

5.0.5 (2019-11-06)

Performance Improvements

  • improvements for webpack@5

5.0.4 (2019-07-26)

Bug Fixes

  • use posix separator for emitting assets (#392) (7f08be6)

5.0.3 (2019-04-24)

Bug Fixes

  • alone [N] interpolation in to option (#375) (70917b7)

5.0.2 (2019-03-22)

Bug Fixes

Performance Improvements

5.0.1 (2019-03-11)

Bug Fixes

  • respect base of glob for context dependencies (#352) (5b407f1)

5.0.0 (2019-02-20)

Bug Fixes

  • copy only modified files when you use patterns with difference to and same context (#341) (e808aa2)
  • handle [contenthash] as template (#328) (61dfe52)
  • handles when you add new files in watch mode and use glob (#333) (49a28f0)
  • normalize path segment separation, no problems when you mixed / and \\ (#339) (8f5e638)
  • throw error if from is an empty string #278 (#285) (adf1046)

Features

  • emit warning instead error if file doesn't exist (#338) (a1c5372)
  • supports copy nested directories/files in symlink (#335) (f551c0d)

BREAKING CHANGES

  • drop support for webpack < 4
  • drop support for node < 6.9
  • debug option was renamed to logLevel, it only accepts string values: trace, debug, info, warn, error and silent
  • plugin emit warning instead error if file doesn't exist
  • change prototype of plugin, now you can to get correct plugin name

4.6.0 (2018-10-31)

Bug Fixes

  • handle undefined and null as stats value (#302) (78c5d12)

Features

  • add support for target path transform (#284) (7fe0c06)

4.5.4 (2018-10-18)

Bug Fixes

  • processPattern: don't add 'glob' as directory when it is a file (contextDependencies) (#296) (5670926)

4.5.3 (2018-10-10)

Bug Fixes

  • processPattern: add glob directory context to contextDependencies (#290) (5fa69db)

4.5.2 (2018-06-26)

Bug Fixes

4.5.1 (2018-03-09)

Bug Fixes

  • package: update cacache v10.0.1...10.0.4 (dependencies) (#238) (0b288f9)

Performance Improvements

  • index: switch to md4 for content hashing (#239) (2be8191)

4.5.0 (2018-03-02)

Features

  • processPattern: add support for {RegExp) matches (pattern.test) (#235) (1861730)

4.4.3 (2018-03-01)

Bug Fixes

  • index: tapable deprecation warnings (webpack >= v4.0.0) (#234) (445d548)

4.4.2 (2018-02-23)

Bug Fixes

  • src/: don't escape non-glob patterns (#230) (0eb2cd5)

4.4.1 (2018-02-08)

Bug Fixes

  • replace pify with simpler promise helpers (#221) (dadac24)

4.4.0 (2018-02-08)

Bug Fixes

  • package: add prepare script (9bf0d99)
  • preProcessPatterns: support glob context paths with special characters (#208) (ea0c05f)
  • support webpack >= v4.0.0 (6a16b3c)

Features

  • use compiler.inputFileSystem instead fs (#205) (158f821)

4.3.1 (2017-12-22)

Bug Fixes

4.3.0 (2017-12-14)

Features

  • add option to cache pattern.transform (pattern.cache) (#176) (20c143b)
  • option for caching transform function (48c19ff)

4.2.4 (2017-12-14)

Refactoring

  • refactor: use native {Promise} instead of bluebird (#178) (a508f14)

4.2.3 (2017-11-23)

4.2.2 (2017-11-23)

Bug Fixes

  • copying same file to multiple targets (#165) (43a9870)

4.2.0 (2017-10-19)

Features

4.1.1 (2017-10-05)

Chore

4.1.0 (2017-09-29)

Bug Fixes

  • Changed default ignore glob to ignore dot files (#80) (08b69a4)
  • Fixed glob as object (1b2c21a)
  • Improved Windows compatibility (#85) (ad62899)
  • Memory leak in watch mode and use Set for performance (#130) (de46fde)
  • subdirectory errors in blob patterns (c2720d0)

Features

  • Added non-wildcard glob support (405d1ec)
  • Added transform method to patterns (#77) (6371eb1)

4.0.1 (2017-09-29)

Bug Fixes

  • Fixed glob as object (1b2c21a)
  • Improved Windows compatibility (#85) (ad62899)
  • subdirectory errors in blob patterns (c2720d0)

Features

  • Added non-wildcard glob support (405d1ec)
  • Added transform method to patterns (#77) (6371eb1)

4.0.0 (2016-10-23)

Bug Fixes

  • Changed default ignore glob to ignore dot files (#80) (08b69a4)

Features

  • Added transform method to patterns (6371eb1)