I expect my copy plugin will move json files to a different directory with a different name based on the name of the folder it came from. For example: app/js/games/aspen/json/test.json will move to /json/aspen-test.json
On Windows, this copies the literal '[1]-test.json' to the new directory, rather than the name of the first capturing group. This works properly in Linux.
new CopyWebpackPlugin([
{
from: 'app/js/**/test.json',
to: 'json/[1]-test.json',
test:/app\/js\/(?:games|controllers)\/([^/]+)\/json\/test.json/
}])
I think using this plugin code in a small repository with a similar directory structure will show the proper result.
Thanks for issue, i think problem related to loader-utils, i will see in near future
Just note: /app\/js\/(?:games|controllers)\/([^/]+)\/json\/test.json/ should be /app\/js\/(?:games|controllers)\/([^/]+)\/json\/test\.json/ (you forget \.). Investigate what is problem.
Problem not in copy-webpack-plugin. Problem in loader-utils as i written above (https://github.com/webpack/loader-utils/blob/master/lib/interpolateName.js#L110). resourcePath contains platform specific path separator, so you regexp doesn't work on windows, unfortunately we can't fix it on plugins side and we can't fix it without major release loader-utils. I created issue https://github.com/webpack/loader-utils/issues/143, we fix it for v2. As workaround you can use (/|\\) instead / in regexp. I closing issue in favor https://github.com/webpack/loader-utils/issues/143. Thanks!
Find problem https://github.com/webpack-contrib/copy-webpack-plugin/pull/353, with one side it is fix, with other it is breaking change, i am afraid release this as patch
Could you at least put a note in the readme about this until a fix is available?
We remove the test option in favor transformPath, using the transformPath option allow to implement any logic, even async, no need write hard to read regexps
Most helpful comment
We remove the
testoption in favortransformPath, using thetransformPathoption allow to implement any logic, even async, no need write hard to read regexps