Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Switch to sass-embedded
Browse files Browse the repository at this point in the history
Hunting down some more reading on sass perf, I found this gh issue:
sass/dart-sass#868. That led to me looking at
sass-embedded as a drop-in replacement for sass. I tried that, and yep,
it does what it says on the tin. Works the same, but async is way faster
and comparable to sync perf (with the benefit of much higher throughput
if you're doing a lot of stuff concurrently). My entire build wall-clock
time is now down to 8s, and the slowest css bundles are 4.5s.

Biggest downside seems to be that dart isn't compatible with musl libc,
so I had to swap the base docker image I was using for my esbuild
pipeline. Unclear to me if there are other tradeoffs.
  • Loading branch information
wfleming committed May 18, 2023
1 parent 8095df0 commit 1a4e17b
Show file tree
Hide file tree
Showing 5 changed files with 1,644 additions and 1,714 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"dependencies": {
"resolve": "^1.22.2",
"sass": "^1.62.0"
"sass-embedded": "^1.62.0"
},
"devDependencies": {
"@types/node": "^18.15.12",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {OnLoadResult} from 'esbuild'
import {StringOptions} from 'sass'
import {StringOptions} from 'sass-embedded'
import {sassPlugin} from './plugin'

export type Type = 'css' | 'style' | 'css-text' | 'lit-css'
Expand Down
4 changes: 2 additions & 2 deletions src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {dirname, parse, relative, resolve, sep} from 'path'
import fs from "node:fs/promises"
import {createResolver, fileSyntax, sourceMappingURL} from './utils'
import {PartialMessage} from 'esbuild'
import * as sass from 'sass'
import {ImporterResult} from 'sass'
import * as sass from 'sass-embedded'
import {ImporterResult} from 'sass-embedded'
import {fileURLToPath, pathToFileURL} from 'url'
import {SassPluginOptions} from './index'

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {SassPluginOptions, Type} from './index'
import {AcceptedPlugin, Postcss} from 'postcss'
import PostcssModulesPlugin from 'postcss-modules'
import {BuildOptions, OnLoadResult} from 'esbuild'
import {Syntax} from 'sass'
import {Syntax} from 'sass-embedded'
import {parse, relative, resolve} from 'path'
import {existsSync} from 'fs'
import {SyncOpts} from 'resolve'
Expand Down
Loading

0 comments on commit 1a4e17b

Please sign in to comment.