Skip to content

feat: Load custom properties CSS file and auto-generate on change#11827

Merged
cdrini merged 5 commits intointernetarchive:masterfrom
lokesh:watch-less-and-generate
Feb 6, 2026
Merged

feat: Load custom properties CSS file and auto-generate on change#11827
cdrini merged 5 commits intointernetarchive:masterfrom
lokesh:watch-less-and-generate

Conversation

@lokesh
Copy link
Collaborator

@lokesh lokesh commented Feb 6, 2026

Load CSS custom properties as a standalone stylesheet and auto-regenerate them on each webpack build.

Technical

  • Webpack build process: Runs scripts/generate-css-custom-properties.js via the beforeCompile hook, so generated-custom-properties.css is always regenerated before a build (including in watch mode).
  • CSS file loading: Adds a <link> tag that loads generated-custom-properties.css so they can be utilized by our web components and other CSS files.
  • Updates generated-custom-properties.css

Testing

  • Run docker compose run --rm home npm run build and verify static/css/less/generated-custom-properties.css is regenerated with the latest values.
  • Run the CSS build in watch mode (docker compose run --rm home npm run watch:css) and change a LESS variable, confirm the custom properties file is regenerated.

Screenshot

Stakeholders

@mekarpeles @cdrini @RayBB

@lokesh lokesh requested a review from RayBB February 6, 2026 06:54
@RayBB
Copy link
Collaborator

RayBB commented Feb 6, 2026

@lokesh I didn't get to try this yet. But based on my other use of this script I have a question.
Is it possible that we make it so it doesn't update the timestamp if nothing else in the file changed?
Otherwise, it will generate often and update the time stamp and probably show up in PRs where it's not needed.

@lokesh
Copy link
Collaborator Author

lokesh commented Feb 6, 2026

@lokesh I didn't get to try this yet. But based on my other use of this script I have a question. Is it possible that we make it so it doesn't update the timestamp if nothing else in the file changed? Otherwise, it will generate often and update the time stamp and probably show up in PRs where it's not needed.

Good point. For now, I've removed the timestamp from the generated file which will prevent unnecessary file modifications that show up in git commits.

We could have the build step generate files and do a diff to compare before deciding on updating the timestamp, but that might be overkill. Went with the simplest solution.

@cdrini cdrini self-assigned this Feb 6, 2026
* DO NOT EDIT THIS FILE DIRECTLY!
* Run: node scripts/generate-css-custom-properties.js
*
* Generated: 2026-01-12T19:33:19.310Z
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wooohooo!! I was wondering what was causing this file to appear modified all the time, great fix!

@cdrini cdrini merged commit 1347b64 into internetarchive:master Feb 6, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

3 participants