从数组中复制WebpackPlugin

时间:2018-03-20 09:29:09

标签: webpack

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

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

1 个答案:

答案 0 :(得分:2)

您无法使用数组,但来自minimatch的数据 所以这样的事情会起作用。

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

或者您只需定义多个来自

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