Fix privacy page stylesheet hash syncing - #149
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the inject-hash.js script to support multiple HTML files by iterating over an array of paths, including both index.html and privacy.html. It also adds an existence check for these files and updates the CSS link in privacy.html with a new hash and an ID. I have no feedback to provide.
There was a problem hiding this comment.
Pull request overview
This PR fixes broken styling on the static privacy page by ensuring its Vite-hashed asset references stay in sync with build output, extending the existing build-time hash injection step beyond public/index.html.
Changes:
- Updated
public/privacy.htmlto use the current hashed CSS filename and addedid="vite-css"so it can be reliably replaced by the injector. - Extended
scripts/inject-hash.jsto update multiple HTML targets (index.htmlandprivacy.html) using the Vite manifest, with per-file success logging.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/inject-hash.js | Applies manifest-driven JS/CSS filename replacement across multiple static HTML files. |
| public/privacy.html | Adds the vite-css link marker and updates the CSS href so the injector can keep it current. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Iterate over manifest keys to find entry points and inject their new names | ||
| Object.keys(manifest).forEach(key => { | ||
| htmlPaths.forEach(htmlPath => { | ||
| if (!fs.existsSync(htmlPath)) { |
There was a problem hiding this comment.
htmlPaths includes files that are intended to be kept in sync, but missing files are currently skipped silently (return without any log). This can hide a path typo or unexpected missing file and lead to shipping an out-of-date HTML page. Consider logging a warning (or failing the script) when a configured HTML target is not found.
| if (!fs.existsSync(htmlPath)) { | |
| if (!fs.existsSync(htmlPath)) { | |
| console.warn(`[Hash Injector] Configured HTML target not found: ${path.relative(projectRoot, htmlPath)}`); |
| Object.keys(manifest).forEach(key => { | ||
| const entryData = manifest[key]; | ||
| if (entryData && (entryData.isEntry || entryData.isDynamicEntry) && entryData.file) { | ||
| // chunk name could be 'main.js' or 'frontend/main.js' |
There was a problem hiding this comment.
The indentation inside the nested Object.keys(manifest).forEach(...) block is inconsistent (the inner block contents are not indented relative to the callback). Please re-indent this section to match the rest of the file to keep it readable and reduce the chance of future editing mistakes.
Motivation
public/index.html, leaving other static pages out of sync with Vite output.Description
public/privacy.htmlto reference the current hashed stylesheet and addid="vite-css"so it can be targeted by the injector.scripts/inject-hash.jsto iterate over anhtmlPathsarray and update bothpublic/index.htmlandpublic/privacy.htmlwith the hashed JS/CSS filenames from the Vite manifest.Testing
npm test(node --test tests/frontend/*.test.js) and all frontend tests passed with 15 tests and 0 failures.Codex Task