-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use dynamic file names for assets #18632
Conversation
42d6537
to
e391c1e
Compare
c255a28
to
35e241a
Compare
Actually the original PR #18348 ( This PR is already much more complex ( Although I still feel that #18348 is better and more suitable for current Gitea, if this PR can handle all cases correctly without introducing hacky methods, then I would have no objection. |
More complex, but the proper solution imho
Yes, it's WIP
I plan to remove all files outside webpack in the future, it's just bad practice and CodeMirror can break anytime with the currently outdated plugins.
Not hacky imho, and I think I've found a solution for development by |
It seems the general recommendation for webpack during development is to not emit hash-based assets (files will pile up in the filesystem until Current solution still has it in by checking the |
1cd8272
to
4be1258
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
Let's keep this open. |
Rebased. Still WIP. |
} | ||
|
||
manifestModified = fi.ModTime() | ||
manifestMutex.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All returns need Unlock
@lunny: time-based cache doesn't work like that. Browser will not even attempt to re-validate a cached resource until cache duration has expired, even if it had already changed on the server. ETag-based cache could do what you want but it would require re-validation (e.g. If-None-Match header) on every request, which will increase server load. Once cache busting via filename works (this PR), I agree, we can make prod/dev the same, but it's still convenient to not have the dev server cache at all. |
// use clean to keep the file is a valid path with no . or .. | ||
f, err := fs.Open(path.Clean(file)) | ||
f, err := fs.Open(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: should path.Clean
in all cases.
On topic here: It might be possible make a "light" version of this PR and introduce Edit: #20813 |
Let's continue this in #20813. I think the solution here with asset manifest is probably too complicated, but will likely be necessary if we ever want to have consistent contenthash in all filenames. |
WIP on dynamic asset filenames which turns
/js/index.js
into/js/index.5ed90373e37c.js
. This is done via webpack-assets-manifest which creates aassets-manifest.json
file which is used by the backend to map the filenames.TODOs:
index.js
andindex.css
assets-manifest.json
for integration testsI'm unsure what the best option is for development rebuilds as the backends need to be able to reload
assets-manifest.json
when it changes, both inside bindata and in the file system. One simple option could be to only use dynamic asset names during the prod build. Another option could be aSIGUSR1
(SIGHUP
is already in use) sent by webpack to the backend, but I don't think it's a portable option.Fixes: #18522