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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS module name generation & CSS pruning #675

Merged
merged 16 commits into from
Mar 11, 2023
Merged

Conversation

rsek
Copy link
Collaborator

@rsek rsek commented Mar 11, 2023

applies various fixes, optimization, and cleanup ahead of sass migration. this reduces the size of the compiled ironsworn.css by ~45% (!).

before:
Screenshot_20230311_020705

after:
Screenshot_20230311_020341

  • write a function to programmatically generate pretty CSS module class names

    • format: ${kebabCase(componentFilename)}__${kebabCase(class)}
    • example: font-icon__wrapper
    • this gives us legible, fairly predictable names that are easily targeted by e.g. user style sheets, and are easy to locate even without the use of dev tools
    • does mean we need to keep our component names unique, but that seems like the best policy regardless
  • normalizes several CSS module class names to match migrate from LESS to SCSS (via PostCSS)聽#567 , and to make the generated class names more concise

  • minify rendered CSS via CSS nano

  • replace autoprefixer with postcss-preset-env, which includes autoprefixer (and offers more detailed configuration)

  • reconfigure browserslist: our previous browserlist was actually much more lenient than even the general-purpose defaults provided by browserslist, so we were generating CSS for browsers that don't even support our compiled JS

  • work out fix for CSS bloat. running vite in library mode inlines images as base64, regardless of the configured size. yikes.

    • there's ~70+ base64 strings in our CSS currently 馃槵
    • there's an open PR for it, but i haven't found any satisfactory workarounds there
    • referencing svg sprites doesn't work... at least in currently available browsers. sigh.
    • at the very least i could set them as CSS variables, then they just appear once? appear only as URLs.
  • Update CHANGELOG.md

@ben ben merged commit 1f840aa into ben:main Mar 11, 2023
@rsek rsek deleted the css-pruning-and-name-gen branch March 12, 2023 00:37
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.

None yet

2 participants