Sunsetting SCSS

オープン
#6,044 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
css, php, scss

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

Discussion

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.

主要言語
PHP
スター
248
フォーク
147
平均マージ
17分
マージ済み PR(30日)
21

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WoltLab/WCF のほかの issue

WoltLab/WCF の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。