Copy-webpack-plugin: Passing empty array is no longer possible

Created on 11 Dec 2019  路  6Comments  路  Source: webpack-contrib/copy-webpack-plugin

The latest release introduced breaking change (options validation). Passing an empty array is no longer possible. So it broke cases like

new CopyWebpackPlugin(condition ? ['./something'] : [])

example: https://github.com/styleguidist/react-styleguidist/blob/master/src/scripts/make-webpack-config.ts#L100

Expected Behavior

I honestly don't know if it's a valid case to support :)

Most helpful comment

Let's fix it :+1:

All 6 comments

Change condition [condition ? new CopWebpackPlugin() : false].filter(Boolean), it is expected empty array is not supported

Yeah, I know, that you can write it this way :) But before passing an empty array didn't trigger an error. So, technically, it's a breaking change.

Let's fix it :+1:

Watching this as it broke a number of projects, pinning temporarily to 5.0.x

In next release it will be returned and you can't use empty array

and you can't use empty array

Why?
You can write this check once inside a plugin instead of everyone of us will write this everywhere:

[ patterns.length ? new CopWebpackPlugin({ patterns }) : false ].filter(Boolean)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

niksmac picture niksmac  路  3Comments

amgohan picture amgohan  路  5Comments

jbruni picture jbruni  路  3Comments

gh67uyyghj picture gh67uyyghj  路  4Comments

stq picture stq  路  5Comments