Copy-webpack-plugin: After each code change, the copy operation of the "copy-webpack-plugin" plug-in is executed at the same time as the recompilation operation.

Created on 13 Jun 2020  ·  23Comments  ·  Source: webpack-contrib/copy-webpack-plugin

webpack: v4.43.0
webpack-dev-server: v3.11.0
copy-webpack-plugin: v6.0.2
html-webpack-plugin v4.3.0
Windows 10 professional edition 1902 18363.900
node.js: v14.4.0
npm: v6.14.5

Describe the bug:
1、
After each code change, the copy operation of the "copy-webpack-plugin" plug-in is executed at the same time as the recompilation operation.
image

To Reproduce:
1、The configuration of "copy-webpack-plugin" is:
image
2、The configuration of "html-webpack-plugin" is:
image
3、The configuration of "webpack" is:
image

Expected behavior:
1、
After each code change, the recompile operation will not be executed at the same time as the "copy-webpack-plugin" plugin's copy operation.
2、
The "copy-webpack-plugin" plug-in will be re copied only when the copied file changes.


This issue was moved from webpack/webpack#11032 by @evilebottnawi. Original issue was by @LP1994.

Community help wanted 4 (important) Patch 4 (inconvenient) Bug

All 23 comments

Set force: false option, you say webpack to rewrite assets if they exists

It's still the same.
V5.0 won't have this problem.

I am currently having the same problem, I do not know if it could help but I downgraded from 6.02 to 5.02 and solved it momentarily.

I am currently having the same problem, I do not know if it could help but I downgraded from 6.02 to 5.02 and solved it momentarily.

In fact, as long as we know what changes have taken place in 6.0 compared with 5.0, we can know what causes this situation in 6.0, but 5.0 will not.

@LP1994 @lunac Please create reproducible test repo, I want to investigate

@LP1994 @lunac Please create reproducible test repo, I want to investigate

I will post the completed configuration and use process. So that you can reproduce the problem.

@LP1994 minimum reproducible test repo, I can't copy code from screenshots, sorry

@LP1994 minimum reproducible test repo, I can't copy code from screenshots, sorry

When I arrive, I will give you the configuration code directly so that you can copy and use it.

@LP1994 thanks

@LP1994 thanks
PS:
Because I have too many complete configurations, I just copy the configuration code related to this plug-in!!!

1、The configuration of "copy-webpack-plugin" is:
copyWebpackPluginConfig_obj = {
patterns: [
{
context: './src/',
from: 'static',
to: './static',
toType: 'dir',
force: true,
globOptions: {
concurrency: 4,
deep: Infinity,
ignore: [
'/.gitignore',
],
},
cacheTransform: true,
},
{
context: './src/workers/',
from: 'tools',
to: './workers/tools',
toType: 'dir',
force: true,
globOptions: {
concurrency: 4,
deep: Infinity,
ignore: [
'
/.gitignore',
],
},
cacheTransform: true,
},
],
options: {
concurrency: 100,
},
},

2、The configuration of "html-webpack-plugin" is:
new htmlWebpackPlugin( {
filename: 'pages/HelloWorld.html',
template: './src/tplEJS/pages/HelloWorld.ejs',
title: 'HelloWorld',
excludeChunks: [],
inject: 'body',
scriptLoading: 'defer',
cache: false,
minify: true,
chunksSortMode: 'auto',
} ),

3、The configuration of "webpack" is:
module.exports = {
// ......Other configuration codes are ignored.
cache: true,
watch: true,
watchOptions: {
aggregateTimeout: 100,
ignored: [
// path.resolve( __dirname, './src/static/' ),
],
poll: 100,
},
parallelism: 4,
profile: true,
devServer: {
contentBase: path.join( __dirname, './dist/devServer/' ),
publicPath: http://localhost:8082/WebProTpl/dist/devServer/pages/HelloWorld.html,
host: 'localhost',
port: 8082,
disableHostCheck: true,
compress: true,
hot: false,
hotOnly: false,
clientLogLevel: 'error',
https: false,
useLocalIp: false,
overlay: {
warnings: true,
errors: true,
},
noInfo: false,
quiet: false,
watchContentBase: true,
watchOptions: {
aggregateTimeout: 100,
ignored: [
// path.resolve( __dirname, './src/static/' ),
],
poll: 100,
},
open: true,
writeToDisk: false,
},
};

@LP1994 thanks

Use the configuration I mentioned above, and then:
After each code change, the copy operation of the "copy-webpack-plugin" plug-in is executed at the same time as the recompilation operation.

@LP1994 Please use git repository, it is unreadable

No need copy all config, just copy part of configuration and code where is the problem

hey @evilebottnawi , I am sorry I am late but here a simple repo that you can clone https://github.com/lunac/test-copy-plugin-webpack

you can run it with npm run watch and changing anything in the scss file will produce different results according to copy-webpack-plugin

with version 5.0.2 after a change it will only emit two files
image

But with version 6.0.2 after change it will emit every file inside the copy plugin config
image

Thank so much for checking this issue.

Thanks

hey @evilebottnawi , I am sorry I am late but here a simple repo that you can clone https://github.com/lunac/test-copy-plugin-webpack

you can run it with npm run watch and changing anything in the scss file will produce different results according to copy-webpack-plugin

with version 5.0.2 after a change it will only emit two files
image

But with version 6.0.2 after change it will emit every file inside the copy plugin config
image

Thank so much for checking this issue.

What you are expressing is what I want to say, and I also encounter this problem.

@LP1994 Please use git repository, it is unreadable

@lunac
What you are expressing is what I want to say, and I also encounter this problem.

Fix will be tomorrow

Fix will be tomorrow

thank you!
Looking forward to the new version!

Fix will be tomorrow

Hello!
The latest version(copy-webpack-plugin v6.0.3) does not solve the problems mentioned above!

@LP1994 It is not fixed yet

The actual issue is that copyUnmodified option is invalid to keep persist assets between rebuilds in v6. #497
Hope that methods can be applied other than disabling the copyUnmodified feature.

Fixed for webpack@5 only, no fixes for webpack@4, because we don't have API for this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niksmac picture niksmac  ·  3Comments

stq picture stq  ·  5Comments

jbruni picture jbruni  ·  3Comments

padinko picture padinko  ·  3Comments

jdeniau picture jdeniau  ·  5Comments