Sunsetting SCSS
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- css, php, scss
- Ambito
- build-system, frontend
Direzione di ricerca
This issue is part of the broader style system overhaul in #6028. Read that initiative alongside this comparison of SCSS and native CSS, then map where SCSS compilation, variables, and generated stylesheets are used in the project. Done means the style system no longer depends on SCSS and supports the CSS delivery and development workflows described here.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Note: This is part of a larger initiative to overhaul the style system and the customization options in general. See #6028 to learn more.
CSS for the longest time was very static and most features focused on achieving new visual effects and layout options, with little to no progress towards the developer experience. CSS preprocessors like LESS or SASS/SCSS filled the gap by providing a single build step that provided a lot of features that ease the day-to-day work with large style codebases. However, CSS continued to evolve and provides a lot of native solutions for these problems today.
Comparison of CSS to Preprocessors Today
The following will use SCSS as the example and focused on the features currently used in our scenario.
| Feature | SCSS | Native CSS | Comment |
|---|---|---|---|
| Selector Nesting | ✅ | ✅ (Baseline 2023) | Nesting selectors allowed to extend an existing selector without having to repeat the entire selector. Over time styles became more focused and component scoped, greatly reducing the need for this feature in the first place. |
| Dynamic Variables | ❌ | ✅ (Baseline) | SCSS variables are replaced on compile time while CSS variables can change their value dynamically, for example, to change formatting based on the color scheme. |
| Functions | ✅ | ❌ | SCSS functions allow to generate CSS based on parameters. Can be emulated to some degree with CSS variables and by manually creating the selectors. |
| Extending Selectors | ✅ | ❌ | Existing selectors can be extended in SCSS which applies the same CSS rules without having to change the CSS classes in the DOM. Used only occasionally and can be replaced by proper CSS classes in the DOM instead. |
| Deriving Values | ✅ | ✅ (Baseline 2024) | Computing colors based on rules, for example, adding transparency to an existing color value. High potential for misuse by using effectively fixed values (like darken()) that fall apart for dark colors. |
| Variables for Media Queries | ✅ | ❌ | It is currently not possible to replicate helper functions like @include screen-md-down in pure CSS without processing the CSS first. This means authors will have to manually copy the selector instead of using a handful of easily memorizable helpers. There is a draft for supporting this through env() but this might still be years away. |
| ACP Options to Toggle Behavior | ✅ | ✅ | Certain options are exposed to the SCSS compiler as variables which allow for some degree of decision making when generating the CSS output. This can possibly be replicated by exporting these values as data attributes on the document/body element. |
| Auto-prefixing of selectors | ✅ | ❌ | Replacement functions in SCSS allow to write standards-compliant CSS by automagically expanding it to vendor specific selectors. Historically this was a great feature but considering the ongoing “Baseline” initiative among all major browsers, this is a thing of the past. |
| Bundling of CSS files | ✅ | ❌ | This can be achieved with very little code on our own and will be required for production. Being able to minify the CSS is nice but it’s unclear if it provides any meaningful advantage after gzip. |
| Swap out files for development | ❌ | ✅ | CSS files can simply be swapped out on-the-fly for development purposes by loading all CSS files “the traditional way”. SCSS requires an extra compilation step to yield the updated CSS. |
| On-demand stylesheets | ❌ | ✅ | SCSS compiles into one big blob, although it should be possible to create separate artifacts. CSS natively is modularized, allowing extra stylesheets to be conditionally included because there are no actual dependencies. Allows for a smaller base stylesheet. |
Other Things to Consider
We’re currently using the legacy rgba(r, g, b, a) syntax to store color values. This works just fine but requires an extra step to allow for dynamic changes, for example, to create a gradient from a color value to its transparent variant (thanks Safari!). For this purpose we’re currently outputting an extra set of variables which only contain the r g b portion of the value.
We should investigate which format is best suited to work with CSS functions, including but not limited to different color formats in general.
Path Forward
Dropping the CSS preprocessors removes quite a large library from our dependencies which is also very computational expensive. Furthermore SCSS encourages certain patterns like derived values, nesting and extending of selectors that could be considered harmful.
CSS has matured so much over the past years, that it provides most building blocks for proper development out-of-the-box in every major browser. Most important, this allows us to finally ship with on-demand stylesheets and a development mode with support for swapping out CSS files on the go, for example, by simply uploading it to a server.
The lack of variables for media queries is quite annoying because the @include screen-* have proven to be easily memorizable as well as guaranteeing a consistent behavior. However, this is just a minor nuisance that does not justify the use of a heavy preprocessor.
- Lingua principale
- PHP
- Stelle
- 248
- Fork
- 147
- Merge medio
- 17m
- PR unite (30g)
- 21
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di WoltLab/WCF
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
WoltLab/WCF#6771 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
HE-Arc/le-panier-du-coin#49 ·
I maintainer di solito rispondono entro 1 giorno
-
15.0
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug: juros do parcelamento travados em 1x no gateway Rede Débito e Crédito 3DS (woo-rede 5.6.0)Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LinkNacional/woo-rede#367 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Lazyload SVG placeholder runs uncached attachment lookups with JSON-escaped URLs on REST responsesApertacustomer report
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Codeinwp/optimole-wp#1253 ·
I maintainer di solito rispondono entro 1 giorno