Open flut1 opened 6 years ago
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.
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.
@hjeti All assets should still be versioned either by a version number folder or hash versioning. To clarify, this is my suggestion:
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 static
folder are still copied by CopyWebpackPlugin
to /version/xxx
, so still with a version number in the folder namefile-loader
) will use hash filenaming and go in /assets
instead of /version/xxx
@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 I've merged your PR
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.