codeforamerica / honeycrisp-gem

A Rails gem with base styles and Javascript for Code for America products
http://honeycrisp.herokuapp.com
MIT License
24 stars 8 forks source link

Add version to CSS & JS assets #276

Closed bengolder closed 3 years ago

bengolder commented 3 years ago

When we generate static CSS & JS files, they should include a specific version number, so that we can better debug issues that arise and understand when static assets are out of date. This is most relevant to SHIBA and any non-ruby projects that use Honeycrisp, because they rely on the generated static assets.

This is done when running rake assets:package creates honeycrisp.min.css and honeycrisp.min.js files that include a comment with the latest honeycrisp version number.

coltborg commented 3 years ago

I think the best approach for this is to insert the version after minification has happened.

sassc doesn't have an option to ignore certain comments on minification, it will remove ALL comments. Hence why we want to add the comment after minificaiton.

Something like: (pseudo code) echo "/* Honeycrisp v$(Cfa::Styleguide::VERSION) Build time: $(date '+%m-%d-%Y %H:%M:%S')n */n$(cat scripts.min.js)" > scripts.min.js

Do this for both honeycrisp.min.css and honeycrisp.min.js