Copy-webpack-plugin: Retain file timestamps after copy

Created on 26 Jul 2019  路  11Comments  路  Source: webpack-contrib/copy-webpack-plugin

  • Operating System:
  • Node Version:
  • NPM Version:
  • webpack Version:
  • copy-webpack-plugin Version:

Feature Proposal

See: https://github.com/angular/angular-cli/issues/14003
It would be nice if files copied using the plugin could retain their original timestamps rather than getting the current date and time.

Feature Use Case

When a build is done it becomes very difficult to determine what has changed and when transferring files to another system the timestamp can not be relied upon for quick checks.

Community help wanted 5 (nice to have) Minor Feature

Most helpful comment

Same case here with Azure Storage, it would be great if we can retain the timestamp of each file so it would prevent it from being re-uploaded. This would speed up most CI/CD pipelines.

All 11 comments

Please clarify what do you mean

When files are copied using the plugin the standard OS file copy is used. The resulting file has a date and time of when the copy was performed. It would be nice if the original file's timestamp were retained.

For example:

Say I have a file:

dir foo.png
02/21/2019 08:50 53,306 foo.png

When it's copied using the plugin it ends up as:
07/26/2019 10:00 53,306 foo.png

It would be nice if the copied file would retain the original February timestamp.

keeping original date/time is invalid because copied files was created/modified at 07/26/2019, i think it is unnecessary for this plugin, and very rare edge, you can create own plugin for this purpose

I got around this problem by using rsync

rsync -a ~/path/to/project/src/assets/ ~/path/to/project/build/assets

We're using files copied by this plugin to upload a static site using aws s3 sync, which looks at file sizes and timestamps.
Currently all files get reuploaded on every sync, which is annoying.

I'll take a stab at implementing this, shouldn't be too hard.

Same case here with Azure Storage, it would be great if we can retain the timestamp of each file so it would prevent it from being re-uploaded. This would speed up most CI/CD pipelines.

Feel free to send a PR

Feel free to send a PR

I have an open branch about this, but I got sidetracked. Perhaps I'll get something complete done this week or the next!

Found another problem with this same root cause:
Chrome devtools workspaces 2.0 is not mapping to local resources correctly when files differ by timestamp.
As a result: webpack bundled code is editable from devtools, where static files are not.

Would be nice to have this option for development env.
IMHO this option should be true by default.

Just as a data point, this would help me.

I use the plugin to grab static assets from some libraries I'm using and put them in my dist directory during the build, then I use rsync or robocopy (depending on platform) to push the build directory to a staging server for testing. Right now, the sync program can't tell that the assets are the same every time, because the files in the build directory always have a newer timestamp than the ones that were last pushed to staging.

Let's close in favor https://github.com/webpack-contrib/copy-webpack-plugin/issues/35, I think we will implement this in near future

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gh67uyyghj picture gh67uyyghj  路  4Comments

RPDeshaies picture RPDeshaies  路  5Comments

cletusw picture cletusw  路  5Comments

BoldBigflank picture BoldBigflank  路  6Comments

serut picture serut  路  3Comments