Skip to content

liuyuchenzh/webpack-copy-noloop-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack-copy-noloop-plugin

Why

When set watch to true, won't trigger infinite loop of updates.

Notice

This is for webpack@4

Install

npm i -D webpack-copy-noloop-plugin
# or
yarn add -D webpack-copy-noloop-plugin

Usage

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

module.exports = {
  plugins: [
    new CopyPlugin({
      list: [
        {
          from: "dir/or/file",
          to: "dir/or/file"
        }
      ]
    })
  ]
};

Config

[root]

new CopyPlugin({
  root: __dirname
});

Set the root for the list config.

If set, then all from and to in the list field will be resolved from root value.

list

from

type from = string;

Source. Could be file or directory.

to

type to = string;

Destination. Could be file or directory.

Type must match the corresponding from. If from is file, then to needs to be file. Same applies for directory.

[pattern]

type pattern = RegExp;

If from is directory then you can use pattern to match desire files.

[filter]

type filter = (from: string, to: string) => boolean;

Similar to pattern, but apply for both directory and file.

[flatten = false]

type flatten = boolean;

If from is directory and using pattern to filter files, then flatten could be set to flatten files in to directory.

[move=false]

type move = boolean;

As the name indicates, whether to move the file/directory or not.

filter function won't work when setting move to true. However, you can still use pattern.

[waitFor=() => Promise.resolve()]

type waitFor = (() => Promise<any>) | number;

Simply delay the copy process due to some reason.

About

webpack copy plugin, won't cause infinite loop.

Resources

License

Stars

Watchers

Forks

Packages

No packages published