I was using version 5.1.1 but this morning I decided to update to 6.0.1.
I changed my configuration from:
new CopyWebpackPlugin([
{
from: publicPath,
ignore: process.env.NODE_ENV !== 'dev' ? ['config.json'] : [''],
to: distPath,
},
]),
to
new CopyWebpackPlugin({
patterns: [
{
from: publicPath,
globOptions: {
ignore: process.env.NODE_ENV !== 'dev' ? ['config.json'] : [''],
},
to: distPath,
},
],
}),
But now I'm getting the following errors:
ERROR in unable to locate '/Users/lusenet/Development/com.sportlink.club.web/public' at '/Users/lusenet/Development/com.sportlink.club.web/public/**/*'
This only happens when I try to run my project in development mode using the webpack-dev-server. Making a distribution build still works fine.
Let me know if you need any more information.
Please provide the information indicated in the template issue
Minimally reproducible repository with a problem
Operating System: macOS Catalina
Node Version: 10.16.0
NPM Version: 6.14.4
webpack Version: 4.43.0
copy-webpack-plugin Version: 6.0.1
That it works.
It doesn't work.
You should use [] for ignore option as the default value.
https://github.com/mrmlnc/fast-glob#ignore
new CopyWebpackPlugin({
patterns: [
{
from: publicPath,
globOptions: {
ignore: process.env.NODE_ENV !== 'dev' ? ['config.json'] : [],
},
to: distPath,
},
],
}),
That indeed was the problem, thanks @cap-Bernardito ! :)
You are welcome ))
I have exactly the same issue. My 5.1.1 config is
new CopyWebpackPlugin([
{ from: path.join('node_modules/foo', '**/*.wasm'), to: '.', flatten: true }
])
For 6.0.1
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'node_modules/foo', '**/*.wasm'),
to: '.',
flatten: true,
},
],
})
Operating System: windows 10
Node Version: 10.20.1
NPM Version: 6.14.4
webpack Version: 4.42.0 (react-scripts)
copy-webpack-plugin Version: 6.0.1
Failed to compile.
Error: Child compilation failed:
unable to locate 'C:\Users\Max\Desktop\console\node_modules\foo\**\*.wasm' at 'C:\Users\Max\Desktop\console\node_modules\foo\**\*.wasm'
- compiler.js:141 childCompiler.runAsChild
[console]/[html-webpack-plugin]/lib/compiler.js:141:18
- Compiler.js:343 compile
[console]/[webpack]/lib/Compiler.js:343:11
- Compiler.js:681 hooks.afterCompile.callAsync.err
[console]/[webpack]/lib/Compiler.js:681:15
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[console]/[tapable]/lib/Hook.js:154:20
- Compiler.js:678 compilation.seal.err
[console]/[webpack]/lib/Compiler.js:678:31
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[console]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1423 hooks.optimizeAssets.callAsync.err
[console]/[webpack]/lib/Compilation.js:1423:35
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[console]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1414 hooks.optimizeChunkAssets.callAsync.err
[console]/[webpack]/lib/Compilation.js:1414:32
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[console]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1409 hooks.additionalAssets.callAsync.err
[console]/[webpack]/lib/Compilation.js:1409:36
@daviddelusenet From readme:
// If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`
path.posix.join(
path.resolve(__dirname, 'src').replace(/\\/g, '/'),
'*.txt'
),
It also doesn't work with a relative path instead of absolute. Like
from: path.join('node_modules/foo', '**/*.wasm'),
output from path.join has those \\ and they are replaced in that case too.
But yes, I missed it in the readme, thank you @evilebottnawi it works
Most helpful comment
You should use
[]forignoreoption as the default value.https://github.com/mrmlnc/fast-glob#ignore