-
-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build enters an infinite loop #602
Comments
Here problems with glob and watching (to he honesty no problems), when you use You can fix it:
it is limitation for using glob |
In theory we add |
So the problem is that the base directory of the globbed files is the root of the project; and since that is being added to the watch list, basically any change to any file or folder inside the root and its subdirectories will trigger a rebuild (in this case I assume In that case shouldn't EDIT: In any case, a |
Yes
Why do not use |
I mean, it is an acceptable working solution, but I have many files in the root directory that I would have to manually add to the ignored list and I don't really like that, it just seems unclean. new CopyWebpackPlugin({
patterns: [
...require('glob').sync('./some-file*.txt')
],
}); This is definitely outside the scope of this plugin, but the cleanest solution would be a way of telling the watcher to only report changes to files that match the original glob pattern within the context directory. That is also, in my opinion, what the user would expect. I understand that watching the directory is necessary, otherwise you'd miss potential new files/directories matching the glob pattern, but I think that there needs to be a way of telling the watcher/compiler that "Yes, you do need to watch the directory, but don't forget why you are watching it: within that directory the only meaningful files that should trigger a rebuild are those that match the pattern(s)" without having to explicitly add the files that do not match the pattern(s) to the ignore list. |
Yes, but it is impossible/hard to implement, we need evaluate glob before running, but it is very reduce performance, even glob doesn't know which files you will get at the end, so any potential changes in directory can be resolved by glob or not, I don't have idea(s) how it is possible to solve without perf problems |
Yeah, that's what I thought. However, the first thing that came to my mind after quickly reading some of the code, was to have something similar to You'd have a Then you would pass the appropriate As far as performance goes, I think there are currently two scenarios:
|
|
I faced the same problem.
Helps solve the problem, but then the copy only happens on the first build |
Fixes double compile bug on startup of dev server with empty static dir Double compile seems to be result of using glob instead of copying file by file webpack-contrib/copy-webpack-plugin#602 (comment)
I've recently upgraded my webpack v4 to v5 and in consequence I had to upgrade this plugin too and after that Im getting infinite loop on dev environment after a file save.
which tries to copy all the image and svg files from the assets folder. Can you please help me figure out what needs to be done in-order to fix this issue? |
@k4mr4n Can you provide webpack configuration? |
@alexander-akait Finally, I managed to fix it by adding the so at the end:
webpack.config:
|
We also get an endless loop here when CopyWebPack is used. |
We have the same issue with
and
When adding
it doesnt rebuild infinitely anymore but the static folder isnt watched anymore. So whenever we change something within the static folder (e.g. we have css files inside the static folder) we would have to restart the whole watch process for it to be copied over into the build directory again (which in our case is really annoying given the fact we have css files in that directory). |
@Ponynjaa Why do you consider this as a bug, if you want static directory, webpack rebuilds then you changed something |
@alexander-akait it does, but it enters an infinite loop when you change something in a static directory. In the meantime we found out, that the problem seems to be, that when you use Our config that triggers the infinite loop looks like this:
Copy-Webpack-Plugin config:
If you change something in Thanks :) |
I was having the same problem. For me the solution was to add this to
I guess |
@josecarlosrx Do you want to improve our docs and add this note there? |
@alexander-akait I would like to but I'm experiencing the problem noted by @corsik, only the first build is copied. Edit: Not trying to discourage this project but a simple solution, until this is patched, could be:
webpack.config.js:
|
Expected Behavior
npm run build -- --watch
should build the project only once.Actual Behavior
Multiple odd things happen.
npm run build -- --watch
builds the project twice.This does not happen with
npm run build
.This does not happen if I remove copy-webpack-plugin from webpack's
plugins
.The build enters an infinite loop if you do either one of these two things:
npm run build -- --watch
./some-file*.txt
or./index.js
./index.js
npm run build -- --watch
Everything works as expected if I remove copy-webpack-plugin from webpack's
plugins
.Code
webpack.config.js
How Do We Reproduce?
Test repo: https://github.com/aleab/copy-webpack-plugin_build-loop
The text was updated successfully, but these errors were encountered: