webpack-copy-noloop-plugin

0.4.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i webpack-copy-noloop-plugin

Weekly Downloads

0

Version

0.4.1

License

MIT

Unpacked Size

121 kB

Total Files

12

Last publish

Collaborators

  • liuyuchenzh