Skip to content
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

chore: migrate from less to scss #3961

Merged
merged 7 commits into from
Jun 27, 2024
Merged

Conversation

grigoriy-reshetniak
Copy link
Contributor

@grigoriy-reshetniak grigoriy-reshetniak commented Jun 23, 2024

What is the previous behavior before this PR?
Less was used to build CSS

What is the new behavior after this PR?
Sass is used to build CSS

Things to consider:

  1. CSS produced by new tools is mostly the same, with small differences:
    • Double quotes are used for font-family property.
    • SCSS produces more digits after the decimal point when performing division.
    • Some rules are generated in a single line instead of with a newline between them.
  2. Sass-loader is inserting SCSS code before the content of the file, not editing pre-existing variable values. So creating a variable with a default value ends up rewriting the value that was set at the beginning of the file.
  3. I had to mute stylelint once because it doesn't recognize nth and if I update it to the latest version, it generates a ton of errors, and fixing them could be way out of scope of migration.

Closes #3116

Copy link
Member

@edemaine edemaine left a comment

Choose a reason for hiding this comment

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

This is looking great!

  1. Could you post a diff of the output CSS other than single/double quote changes?
  2. I believe Sass !default values fix this issue.
  3. Maybe you could update stylelint in a future PR? I don't think this is a high priority though.

One omission I noticed:

  • docs/font.md mentions src/fonts.less and needs to change. As an alternative to suggesting changing the file, I think we can suggest overriding the variable.

src/styles/fonts.scss Outdated Show resolved Hide resolved
src/styles/fonts.scss Outdated Show resolved Hide resolved
@grigoriy-reshetniak
Copy link
Contributor Author

grigoriy-reshetniak commented Jun 24, 2024

Left is Less compilation result, right is Sass.

SCSS produces more digits after the decimal point when performing division.

image

Some rules are generated in a single line instead of with a newline between them

image

Also muting comment applied for each style that was generated in loop
image

katex.min.css differs only in digits after comma.

Copy link
Member

@edemaine edemaine left a comment

Choose a reason for hiding this comment

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

Whoops, I wrote these comments but then forgot to publish them. Sorry!

docs/font.md Outdated
@@ -2,7 +2,7 @@
id: font
title: Font
---
By changing the variables in the `src/fonts.less` file,
By changing the variables in the `src/fonts.scss` file,
Copy link
Member

Choose a reason for hiding this comment

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

This path is incorrect (you moved to src/styles/fonts.scss).

Maybe we should also document how to override the things you can by using src/styles/fonts.scss/src/fonts/katex.scss directly and setting some variables, especially if you already have SCSS in your build chain.

Originally I was thinking one thinking of a new top section, titled something like "simple overrides with SCSS". But it might make sense in each section where it's relevant (the last two) how you can modify by using src/style/*scss instead of dist/*css.

In other words, we should document the actual user-visible "feature" of this PR. 🙂 (though a release won't actually trigger with a chore commit message...)

I could also take a stab at writing this if you'd prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could also take a stab at writing this if you'd prefer.
Yes please, or at least part of it so I would better understand the desired outcome and could do it myself in other chapters.

I wasn't sure if that should be a chore, but CSS artifact hasn't changed much so I've decided to name it this way, please let me know if I need to reword the commit.

Copy link
Member

@edemaine edemaine Jun 27, 2024

Choose a reason for hiding this comment

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

I wondered this too, but I think in the end chore is the best description.

I added some description about how to override variables for users of Sass. Could you review? Here's a rendered version. Then I think this is good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good to me.

docs/font.md Outdated Show resolved Hide resolved
@edemaine edemaine merged commit ec46dee into KaTeX:main Jun 27, 2024
8 checks passed
@grigoriy-reshetniak grigoriy-reshetniak deleted the less-to-scss branch June 28, 2024 05:10
@KaTeX-bot
Copy link
Member

🎉 This PR is included in version 0.16.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from Less to SCSS?
3 participants