Skip to content

Support sass files in pegasus/sites.v3/code.org/public/css - #46896

Merged
jamescodeorg merged 1 commit into
stagingfrom
jamescodeorg/pegasus-sass-2
Jun 22, 2022
Merged

Support sass files in pegasus/sites.v3/code.org/public/css#46896
jamescodeorg merged 1 commit into
stagingfrom
jamescodeorg/pegasus-sass-2

Conversation

@jamescodeorg

@jamescodeorg jamescodeorg commented Jun 16, 2022

Copy link
Copy Markdown
Contributor

.scss files placed in the existing pegasus/sites.v3/code.org/public/css directory will now be automatically compiled to .css files and can be retrieved from the url path /css/generated Note that this uses our existing pattern that relies on the sass gem which is past end-of-life.

Links

  • jira ticket: LP-2388
  • Commit that originally added sass support for /shared/css

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@jamescodeorg
jamescodeorg force-pushed the jamescodeorg/pegasus-sass-2 branch from 1261474 to 565ffbb Compare June 17, 2022 00:02
@jamescodeorg jamescodeorg changed the title Support sass in pegasus (test) Support sass files in pegasus/sites.v3/code.org/public/css Jun 17, 2022
Comment thread pegasus/router.rb Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Does putting the .scss files in pegasus/sites.v3/code.org/public/css alongside regular css files sound good? Or should we put them in a separate directory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think for easier access they can live alongside .css files in the /public/css directory. Happy to defer to the others though.

@jamescodeorg
jamescodeorg force-pushed the jamescodeorg/pegasus-sass-2 branch from 565ffbb to d78e17a Compare June 17, 2022 00:13
@jamescodeorg
jamescodeorg requested review from a team, breville, davidsbailey and kelbyhawn June 17, 2022 16:06
Comment thread pegasus/router.rb
# Note: shared_resources.rb has additional configuration for Sass::Plugin
Sass::Plugin.options[:cache_location] = pegasus_dir('cache', '.sass-cache')
Sass::Plugin.options[:css_location] = pegasus_dir('cache', 'css')
Sass::Plugin.options[:template_location] = shared_dir('css')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this redundant configuration for /shared/css in Pegasus.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you provide a bit more context on why this is redundant and what these options represent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The "official" documentation appears to be no longer available, but here's a fork: http://paulirish.github.io/Sass-reference/. Very briefly, what the gem does is looks for sass files in css_location, compiles them, and writes the output to template_location. I've replaced the existing way of configuration them in options (which allows for a single mapping) to calling add_template_location which allows for configuring multiple mappings.

We used to configure this particular mapping (pegasus/cache/css --> shared/css) redundantly in pegasus and in shared, possibly because of some pegasus tests issues. This mapping is now only configured in shared_resources.rb and the new pegasus-specific sass directory mapping is configured here. I've attempted to fix the test issue a different way (see change in test_pegasus_documents.rb) and will keep an eye if that's sufficient.

@kelbyhawn kelbyhawn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you James!

@maureensturgeon maureensturgeon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How did you go about testing the changes here?

configure do
# Note 1: pegasus/router.rb has additional configuration for Sass::Plugin
# Note 2: the generated css files written to /pegasus/cache/css are served
# from the url path /shared/css (see route below)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

when I add a .scss file pegasus/sites.v3/code.org/public/css/dave.scss, then restart the local server and load a pegasus page, I see a .css file show up in pegasus/sites.v3/code.org/public/css/generated/dave.css. so far so good. However now I am wondering, how does pegasus/cache/css come into play? also, what url path would I use to access my new css file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The cache stores some kind of internal intermediate parsed version of the .scss file (with an extension of .scssc). The official documentation is no longer available, but I found a copy and there's a little bit more information about caching here.

The new css file can be accessed at code.org/css/generated/dave.css.

@jamescodeorg

jamescodeorg commented Jun 21, 2022

Copy link
Copy Markdown
Contributor Author

How did you go about testing the changes here?

Good question! :-) I used Kelby's test html and scss files locally and verified that the html rendered as expected. I'm relying on Drone to verify that the change to the tests works. Finally, I'm expecting the eyes tests to provide broader coverage across the site to make sure I haven't broken anything.

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

all makes sense, thank you James!

@jamescodeorg
jamescodeorg merged commit 823e52d into staging Jun 22, 2022
@jamescodeorg
jamescodeorg deleted the jamescodeorg/pegasus-sass-2 branch June 22, 2022 00:15
@breville

Copy link
Copy Markdown
Member

This is great!

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.

5 participants