Sunsetting SCSS

Đang mở
#6,044 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
css, php, scss
Lĩnh vực
build-system, frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
248
Fork
147
Merge trung bình
17 phút
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của WoltLab/WCF

Tất cả issue của WoltLab/WCF

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.