Infinite reload with CopyWebpackPlugin

Open
#4,232 31 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
devtools

Research direction

Start with the linked reproduction repository and run webpack serve using the shown CopyPlugin pattern. Edit and save example.js repeatedly, then trace the webpack-dev-server watch and reload behavior to identify why recompilation repeats. Done means a source change causes one recompilation rather than an infinite reload loop.

Written by the indexing model from the issue text.

Description

Bug report

Webpack dev server reloads infinitely after changes in the src code when I use CopyWebpackPlugin with requirejs such like that:

    new CopyPlugin({
      patterns: [
        {
          from: 'requirejs/**/*',
          to: '3rdparty',
          context: '../../node_modules',
        },
      ],
    }),

Here are the versions I have:

    "copy-webpack-plugin": "^10.2.0",
    "webpack": "^5.64.4",
    "webpack-cli": "^4.9.1",
    "webpack-dev-server": "^4.7.2"
Actual Behavior

When I run the command: webpack serve and I modify the code.
Webpack recompiles but after it is written compiled successfully, it recompiles again and again...

Expected Behavior

I should recompile only once after change done in the src code.

How Do We Reproduce?

You can find here a repo to reproduce it.

  • Run webpack serve
  • Change the src code (example.js) and save
  • You have to try several times in a row to change the code, generally it does not happen the first time but after several changes (last time I had to change 10 times the src code to reproduce the infinite reload)
Please paste the results of npx webpack-cli info here, and mention other relevant information
  System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 12.98 GB / 31.73 GB
  Binaries:
    Node: 14.17.5 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.2.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 97.0.4692.99
    Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.76)
    Internet Explorer: 11.0.19041.1202
  Packages:
    copy-webpack-plugin: ^7.0.0 => 7.0.0
    fork-ts-checker-webpack-plugin: ^6.5.0 => 6.5.0
    html-webpack-plugin: ^5.5.0 => 5.5.0
    raw-loader: ^4.0.2 => 4.0.2
    ts-loader: ^9.2.6 => 9.2.6
    webpack: ^5.64.4 => 5.64.4
    webpack-cli: ^4.9.1 => 4.9.1
    webpack-dev-server: ^4.7.2 => 4.7.3
Dominant language
JavaScript
Stars
7.9k
Forks
1.5k
Avg merge
2d 12h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from webpack/webpack-dev-server

All issues in webpack/webpack-dev-server

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.