vue-skeleton icon indicating copy to clipboard operation
vue-skeleton copied to clipboard

Don't output webpack generated assets in a version number folder

Open flut1 opened this issue 7 years ago • 5 comments

We are already using hash filenaming for some assets. Which is great, because this optimizes caching: changed files get a different filename but assets that have not changed will still have the same path so they are cached by the browser. However, by putting assets in a /version/xxxx folder the path will change on every build, regardless of the contents of the asset has changed. This makes the hash in the filename redundant.

flut1 avatar Jun 19 '18 13:06 flut1

We can do it but assets that are in the static folder will not be versioned when we change this and can be cached by the server. So we need a solution for those files. We can maybe add a hash to the static folder so they are never cached.

hjeti avatar Jun 20 '18 13:06 hjeti

It's fine to have both, a version folder for static content (images, json, videos) that is loaded by html or xhr requests, and have the asset folder outputted by webpack with a hash in the filename.

Only thing that needs to be done is having a proper cleanup script that uses information from each build to know which files aren't used anymore in the recent X builds. We already have something for another project, and could make that available as node module to include here as well.

ThaNarie avatar Jun 20 '18 13:06 ThaNarie

@hjeti All assets should still be versioned either by a version number folder or hash versioning. To clarify, this is my suggestion:

  • generally speaking, all assets go through webpack. We keep the static and staticRoot folder in the repository, but we only use this for exceptional cases where it's not practical to use webpack. See #58
  • assets that we put in the static folder are still copied by CopyWebpackPlugin to /version/xxx, so still with a version number in the folder name
  • all assets that go through webpack (including for example images loaded through file-loader) will use hash filenaming and go in /assets instead of /version/xxx

flut1 avatar Jun 20 '18 13:06 flut1

@hjeti I have this ready now but it's waiting for #82. Can you merge it so I can create a new PR? All outstanding comments have been resolved.

flut1 avatar Nov 14 '18 12:11 flut1

@flut1 I've merged your PR

hjeti avatar Nov 14 '18 13:11 hjeti