Direkt zum Inhalt

Devbits

Kleine Code-Schnipsel aus unserem Alltag mit Drupal, PHP und DevOps: Problem, Lösung, Code.

13.11.2025 | Holger Weischenberg

Simple SCSS compiler setup

A simple solution is needed to compile SCSS to CSS in a legacy project.

{
  "name": "Foo project",
  "scripts": {
    "sass-dev": "sass --watch --update --style=expanded src/scss:dist/css",
    "sass-prod": "sass --no-source-map --style=compressed src/scss:dist/css"
  },
  "devDependencies": {
    "sass": "^1.86.0"
  }
}

Issue:

A simple solution is needed to compile SCSS to CSS in a legacy project.

Solution:

Compile SCSS using npm script `npm install sass --save-dev`

13.11.2025 | Holger Weischenberg

Consider the user's preference for dark or light system colors

The theme should take into account whether the user has selected dark or light colors in the OS settings.

/* Default theme */
:root {
  --Background-Color: #fff;
  --Text-Color: #000;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --Background-Color: #000;
    --Text-Color: #fff;
  }
}

Issue:

The theme should take into account whether the user has selected dark or light colors in the OS settings.

Solution:

Use the prefers-color-scheme CSS media feature. See also: documentation at developer.mozilla.org.