Copy-webpack-plugin: Not copy new file in watch mode

Created on 12 Apr 2018  路  7Comments  路  Source: webpack-contrib/copy-webpack-plugin

I use

new CopyWebpackPlugin([
    'res/**/*.*'
])

and

webpack -w --mode=development

When watching, if I create a new file (like res/test.txt), it would not copy to the output path.
I must restart webpack.

4 (important) Patch 3 (broken) Bug

Most helpful comment

When webpack in watch mode, he use memory-fs to increase perf and you can't see files in file system when you in watch mode, it is expected. I update readme about this in near future. Solution:

  1. https://github.com/webpack/webpack-dev-middleware#writetodisk
  2. write-file-webpack-plugin

All 7 comments

@k8w strange, can you create minimum reproducible test repo?

Any update on this?

I can confirm the issue (using [email protected] and [email protected]). It also doesn't work when using webpack-dev-server instead of watch mode.

EDIT: I just read about write-file-webpack-plugin in your readme and will give that a try when using webpack-dev-server.

When webpack in watch mode, he use memory-fs to increase perf and you can't see files in file system when you in watch mode, it is expected. I update readme about this in near future. Solution:

  1. https://github.com/webpack/webpack-dev-middleware#writetodisk
  2. write-file-webpack-plugin

@evilebottnawi The issue is not about it not writing files to filesystem, but about it not noticing new files.

I've run into it with webpack-dev-server. I believe it has to do with it not adding dependencies when from is a glob, as opposed to dirs, and files.

The workaround is to, e.g., replace 'src/assets/**/*' with {from: 'src/assets', to: 'assets'}.

@x-yuri please create minimum reproducible test repo

@evilebottnawi Doesn't the one from the earlier post work for you? It says:

If I add a 3.txt into res, it would not trigger webpack recompile.(watch mode)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmarcautan picture dmarcautan  路  5Comments

cletusw picture cletusw  路  5Comments

alexprice1 picture alexprice1  路  5Comments

lewayjack picture lewayjack  路  5Comments

stq picture stq  路  5Comments