从数组复制WebpackPlugin

maz*_*zza 2 webpack

有没有办法通过CopyWebpackPlugin “from”中的数组设置文件路径。我的意思是这样的

new CopyWebpackPlugin([
            {
                from: [
                    './dir1/file1',
                    './dir2/file2',
                ],
                to: 'assets/'
            }
        ])
Run Code Online (Sandbox Code Playgroud)

luk*_*eke 5

您不能使用数组,但可以使用minimatch 中的globs
所以类似这样的事情会起作用。

new CopyWebpackPlugin([
    { from: './+(dir1|dir2)/+(file1|file2)', to: 'assets/' },
])
Run Code Online (Sandbox Code Playgroud)

或者你只是定义多个 from to

new CopyWebpackPlugin([
    { from: './dir1/file1', to: 'assets/' },
    { from: './dir2/file2', to: 'assets/' },
])
Run Code Online (Sandbox Code Playgroud)