Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flut1 opened this issue Jun 19, 2018 · 5 comments
Open

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

flut1 opened this issue Jun 19, 2018 · 5 comments

Comments

@flut1
Copy link
Collaborator

flut1 commented Jun 19, 2018

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.

@hjeti
Copy link
Owner

hjeti commented Jun 20, 2018

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.

@ThaNarie
Copy link

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.

@flut1
Copy link
Collaborator Author

flut1 commented Jun 20, 2018

@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 Use webpack to load locale modules #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
Copy link
Collaborator Author

flut1 commented Nov 14, 2018

@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.

@hjeti
Copy link
Owner

hjeti commented Nov 14, 2018

@flut1 I've merged your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants