Skip to content

Drop the sass dependency and ship plain CSS - #2362

Merged
enyo merged 1 commit into
mainfrom
plain-css
Sep 13, 2026
Merged

Drop the sass dependency and ship plain CSS#2362
enyo merged 1 commit into
mainfrom
plain-css

Conversation

@enyo

@enyo enyo commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Stacked on #2361. The two stylesheets used sass for nesting, a handful of variables and one math.div call. None of that needs a compiler.

sass is gone from the package. The sources are now the flattened CSS sass was producing anyway.

Flattened, not nested

Native CSS nesting only reached browsers in 2023 — well above the range a library targeting es2017 and supporting everything except Internet Explorer can assume. So the nesting is resolved rather than translated.

esbuild minifies, with an explicit target

It was already in the tree as vite's own dependency, so this trades one direct dependency for another rather than adding one — and sass is by far the larger install.

The target is pinned to chrome58,firefox54,safari11,edge16, matching what the es2017 JS build implies. That is not cosmetic: without it esbuild rewrites every rgba() to hex-with-alpha (rgba(0,0,0,.9)#000000e6), which is syntax newer than the library claims to support. With the target set, rgba() survives and the only hex left is a plain six-digit one.

Verified declaration by declaration

Not eyeballed — I parsed both the old sass output and the new esbuild output into (selector, property, value) sets and compared them.

dropzone.css has the same 177 declarations before and after. Every difference is a value-level equivalence esbuild applies:

sass esbuild
padding: 20px 20px padding: 20px
translateY(0px) translateY(0)
rgba(0, 0, 0, 0) transparent
300ms .3s
scale(1.05, 1.05) scale(1.05)
100% { } in keyframes to { }

basic.css goes from 35 declarations to 33. Both losses are a left: 30px that a left: 50% three lines later in the same block already overrode — dead in the original too.

252 unit tests, 3 library end-to-end specs and the 7 website specs all pass; the website consumes dist/dropzone.css directly, so it exercises the new output.

One thing I got wrong first

The first push of this branch deleted both .scss files and added neither .css file. packages/dropzone/src/.gitignore contained *.css and *.map, left from when sass compiled next to the sources — harmless while the stylesheets were sass, and silently swallowing both new files the moment .css became the source. git status showed the deletions and simply never mentioned the additions.

That file is deleted here too. I checked the fix by extracting the commit with git archive into a clean directory and building from that alone: the stylesheets are present and the output is byte-identical to the working-tree build.

Not done here

Moving the variables to CSS custom properties would let users retheme without rebuilding — a genuine improvement, but a feature and a new public surface, so it does not belong in a conversion whose whole claim is that nothing changed.

@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.42% 880 / 1108
🔵 Statements 79.77% 927 / 1162
🔵 Functions 92.89% 196 / 211
🔵 Branches 76.46% 510 / 667
File CoverageNo changed files found.
Generated in workflow #130 for commit 07d3876 by the Vitest Coverage Report Action

@enyo
enyo added this pull request to stack #2364 September 12, 2026 17:56
Base automatically changed from typescript to main September 13, 2026 09:47
@enyo
enyo force-pushed the plain-css branch 2 times, most recently from 1cc3d3f to 64393d4 Compare September 13, 2026 10:16
The two stylesheets used sass for nesting, a handful of variables and one
math.div call. None of that needs a compiler: the sources are now the
flattened CSS sass was producing anyway, and sass is gone from the package.

Flattened rather than nested. Native CSS nesting only reached browsers in
2023, well above the range a library targeting es2017 and supporting
everything except Internet Explorer can assume.

Lightning CSS minifies them. It is the more thorough of the minifiers tried:
it drops a `background: #999` fallback that no browser in range needs,
shortens `transition: opacity .3s ease` to `.3s` because ease is the default,
and removes a dead `display: block` that was being overridden on the very
next line -- which is in the scss too, and is removed at the source here.

The supported browsers are declared once, as a browserslist field in
package.json, and the build reads them with --browserslist rather than
repeating a list of versions inside a script. That range is the one the
es2017 JavaScript target implies, and it is load-bearing: given a modern
range instead, Lightning CSS rewrites every rgba() into hex-with-alpha, which
is newer syntax than this library claims to support. Checked by widening the
field and watching the output change.

The output was compared declaration by declaration against what sass
produced: 175 effective declarations before and after in dropzone.css, 33 in
basic.css, no difference once value-level equivalences are normalised.

watch-css is removed rather than ported. It existed because sass had a
--watch flag; lightningcss has none, nothing referenced the script, and a
script called watch-css that does not watch is worse than no script.

src/.gitignore is deleted with the stylesheets. It ignored *.css and *.map
next to the sources, which was harmless while they were sass -- and silently
swallowed both new files the moment .css became the source, including hiding
them from the formatter.
@enyo
enyo merged commit db990df into main Sep 13, 2026
3 checks passed
@enyo
enyo deleted the plain-css branch September 13, 2026 10:31
@github-actions github-actions Bot mentioned this pull request Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant