Copy-webpack-plugin: Files are missing after a recompile / since v6 (continue!)

Created on 19 May 2020  路  17Comments  路  Source: webpack-contrib/copy-webpack-plugin

All 17 comments

@martinoppitz Please create minimum reproducible test repo, you still have invalid deps, respect time of other developers, you have a lot of outdated copy-webpack-plugin and html-webpack-plugin packages in package-lock.json, you build steps still doesn't work

@evilebottnawi I have respect f眉r f眉r developer time and will prepere a tiny example. It would be easier to focus on our isseu.

  • Operating System: Win10
  • Node Version: 12.13.1
  • NPM Version: 6.14.5
  • webpack Version: 4.42.0
  • copy-webpack-plugin Version: 6.0.1

Expected Behavior

Develop the app in serve mode. Change files and webpack recompile the app and refresh the webpage in the browser. All files are available in the virtual webhost storage.

FYI: I will not copy files a the disk. The static files will be copied and the bundled files too. But since v6 it does not work anymore.

Actual Behavior

Develop the app in serve mode. Change files and webpack recompile the app and refresh the webpage in the browser. The files are compiled missed, everything else are available.

Code

See: https://github.com/martinoppitz/leanup/blob/master/cli/core/webpack.config.js

new CopyWebpackPlugin({
  patterns: [
    {
      from: path.resolve(process.cwd(), 'public'),
    },
  ],
}),

How Do We Reproduce?

  • git clone https://github.com/martinoppitz/copy-webpack-plugin-v6.git
  • npm install
  • npm start
  • the app is visible
  • make changes in the app
  • the app is not visible

@martinoppitz Minimum reproducible test repo means do not using boilerplates/cli/etc tools. I don't know where leanup stores configurations, I don't know nothing about leanup and how it uses webpack. If every developer reports bugs in this style, I will spend the whole day to solving one problem.

Problem in html-webpack-plugin, for some reason plugins thinks that the assets have not changed, but they are changed, please create an issue in html-webpack-plugin repo, we can't fix it on our side.

Reason - https://github.com/jantimon/html-webpack-plugin/blob/master/index.js#L161, this is an invalid cache check

/cc @jantimon

Also in webpack@5 adding assets on emit event is deprecated

For caching purpose I recommend to store compilation hash from the previous compilation

You can disable caching to slow down the build and recompile files on every run.

Do you have an example for individual caching?

@jantimon It doesn't work with zero configuration, it is a bug and need to fix, I provide line which causes problems, setup simple case with HtmlWebpackPlugin + CopyWebpackPlugin and will see a problem

Cool please provide any ideas which might help to fix this

As minimal repo you can clone this code sandbox:
https://codesandbox.io/s/html-webpack-plugin-body-tag-filtering-fuzxb

@jantimon

For caching purpose I recommend to store compilation hash from the previous compilation

Now cache implementation is wrong

Sorry I have no idea what you mean - how can a hash help out here?

@jantimon A lot of developers have an issue, please solve it ASAP, use should store previously hash of compilation to avoid problems with invalidation of hash when you are in watch mode. What is the problem to fix it?

@evilebottnawi Make a PR in html-webpack-plugin repository to provide your fix.

@martinoppitz Sorry I don't have enough time, the package has its own developers, and this problem is very easy to solve, I am focus on more big problems right now

Unfortunately almost all development done for the html-webpack-plugin is by me for free in my spare time.
My wife is going to give birth in the next days so if someone needs this feature any time soon please help to find out how a possible solution might look like.

Otherwise please try:

new HtmlWebpackPlugin({
  cache: false
})

@jantimon I tried out cache: false it works inside @leanup/cli.

At the moment it is okay, I hope we find time to make the smartest fix.

cu and a nice day

@jantimon Don't worry, enjoy life :smile: if it is not fixed, I will return to this after and fix it (I am free for this in the next month)

@martinoppitz Can you open an issue in HtmlWebpackPlugin repo?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amgohan picture amgohan  路  5Comments

Jocs picture Jocs  路  4Comments

gh67uyyghj picture gh67uyyghj  路  4Comments

stq picture stq  路  5Comments

nickenchev picture nickenchev  路  3Comments