webpack - 从数组中复制 WebpackPlugin

标签 webpack

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

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

最佳答案

你不能使用数组,而是来自 minimatch 的 globs
所以像这样的东西会起作用。

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

或者你只定义多个 from to

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

关于webpack - 从数组中复制 WebpackPlugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49380507/

相关文章:

node.js - 使用 html-webpack-plugin 在开发模式下在 webpack 中构建 HTML

vue.js - 某些 .vue(和 .ts)文件的 Webpack 源映射不再包含原始代码(sourcesContent)

ruby-on-rails - 如何将 select2.js 的需求从链轮迁移到 webpacker

javascript - NPM模块导入时抛出错误

javascript - 我在 webpack.DefinePlugin 中定义的变量未定义

css - Laravel 5.4 从 Elixir 升级到 Webpack 会破坏带有多个 SASS 文件的 js 编译

reactjs - React+TypeScript+WebPack 中的一个问题 with typings-for-css-modules-loader

javascript - Webpack Dev Server 不热重载,需要手动构建 webpack

Laravel 混合编译依赖

javascript - Webpack:node_modules/css/index.js 没有返回函数