webpack-copy-noloop-plugin v0.4.1
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-pluginUsage
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. Iffromis file, thentoneeds 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.
filterfunction won't work when settingmovetotrue. However, you can still usepattern.
waitFor=() => Promise.resolve()
type waitFor = (() => Promise<any>) | number;Simply delay the copy process due to some reason.