From: Mark Otto Date: Thu, 11 Jun 2026 16:48:28 +0000 (-0700) Subject: Fix dark mode on built site by bumping browserslist (#42471) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65a486cef51be2a6156930c9ed3dd0e83b169097;p=thirdparty%2Fbootstrap.git Fix dark mode on built site by bumping browserslist (#42471) * Fix dark mode on built site by avoiding Lightning CSS light-dark() polyfill Lightning CSS was lowering native light-dark() to a --lightningcss-light/dark custom-property toggle because our browserslist floors predated native support. That polyfill breaks data-bs-theme dark mode on the minified (production) CSS, so dark examples rendered light on Netlify while working in dev. - Bump browserslist floors to the first versions with native light-dark() (Chrome/Edge 123, Safari/iOS 17.5; Firefox 121 already covered) - Exclude Features.LightDark in css-minify as a guard against regressions * Update .browserslistrc for browser support and comments Removed comment about CSS light-dark polyfill and updated browser support. * Bump browserslist floors to Chrome/Edge 130, Firefox 132, Safari/iOS 18 Raises support floors as far as possible while keeping ~90.8% global coverage, staying on versions with native light-dark() so Lightning CSS does no polyfilling. --- diff --git a/.browserslistrc b/.browserslistrc index 7acddfb1be..7527cf1513 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -2,9 +2,13 @@ last 2 major versions not dead -Chrome >= 120 -Firefox >= 121 -iOS >= 15.6 -Safari >= 15.6 -not Explorer <= 11 +# Floors kept on versions with native CSS `light-dark()` (and nesting) so +# Lightning CSS doesn't lower them to the brittle custom-property polyfill that +# broke `data-bs-theme` dark mode. Raised as far as we can while staying above +# 90% global coverage (~90.8%). +Chrome >= 130 +Edge >= 130 +Firefox >= 132 +iOS >= 18.0 +Safari >= 18.0 not kaios <= 2.5 # fix floating label issues in Firefox (see https://github.com/postcss/autoprefixer/issues/1533) diff --git a/build/css-minify.mjs b/build/css-minify.mjs index 6f1d112aa3..19082d61fc 100644 --- a/build/css-minify.mjs +++ b/build/css-minify.mjs @@ -9,7 +9,7 @@ import fs from 'node:fs' import path from 'node:path' -import { transform, browserslistToTargets } from 'lightningcss' +import { transform, browserslistToTargets, Features } from 'lightningcss' const distDir = path.join(process.cwd(), 'dist/css') @@ -48,7 +48,11 @@ for (const file of cssFiles) { minify: true, sourceMap: true, inputSourceMap: inputMap ? JSON.stringify(inputMap) : undefined, - targets + targets, + // Never lower `light-dark()`: its custom-property polyfill breaks our + // `data-bs-theme` dark mode. We bumped browser support to versions with + // native support to fix this, but this guards against a regression. + exclude: Features.LightDark }) // Write minified CSS with source map reference