Skip to content

Commit

Permalink
Update to use the Dart Sass binary and the new v2 protocol
Browse files Browse the repository at this point in the history
E.g. use `sass --embedded`.

Note taht this will bumb to a new major version of this library (v2).

If you need to support the old protocol/binary, use the v1 (root path) version.

```bash
name                             old time/op    new time/op    delta
Transpiler/SCSS-10                  114µs ± 0%     145µs ± 1%  +26.40%  (p=0.029 n=4+4)
Transpiler/Start_and_Execute-10    25.6ms ± 2%    26.0ms ± 3%     ~     (p=0.486 n=4+4)
Transpiler/SCSS_Parallel-10        89.0µs ± 2%    44.4µs ± 3%  -50.12%  (p=0.029 n=4+4)

name                             old alloc/op   new alloc/op   delta
Transpiler/SCSS-10                 1.33kB ± 1%    1.33kB ± 0%     ~     (p=1.000 n=4+4)
Transpiler/Start_and_Execute-10    22.4kB ± 1%    22.4kB ± 1%     ~     (p=0.886 n=4+4)
Transpiler/SCSS_Parallel-10        1.34kB ± 3%    1.33kB ± 1%     ~     (p=1.000 n=4+4)

name                             old allocs/op  new allocs/op  delta
Transpiler/SCSS-10                   18.0 ± 0%      18.0 ± 0%     ~     (all equal)
Transpiler/Start_and_Execute-10       144 ± 1%       150 ± 0%   +4.16%  (p=0.029 n=4+4)
Transpiler/SCSS_Parallel-10          18.0 ± 0%      18.0 ± 0%     ~     (all equal)
```

See gohugoio/hugo#11059
Fixes #15
  • Loading branch information
bep committed Jun 8, 2023
1 parent 9f9f1c1 commit c47c03e
Show file tree
Hide file tree
Showing 7 changed files with 644 additions and 688 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
name: Test
env:
DART_SASS_VERSION: 1.56.1
SASS_VERSION: 1.56.1
jobs:
test:
strategy:
Expand All @@ -19,24 +19,25 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Install dart-sass-embedded Linux
- name: Install dart-sass Linux
if: matrix.os == 'ubuntu-latest'
run: |
curl -LJO "https://github.com/sass/dart-sass-embedded/releases/download/${DART_SASS_VERSION}/sass_embedded-${DART_SASS_VERSION}-linux-x64.tar.gz";
tar -xvf "sass_embedded-${DART_SASS_VERSION}-linux-x64.tar.gz";
echo "DART_SASS_EMBEDDED_BINARY=$GITHUB_WORKSPACE/sass_embedded/dart-sass-embedded" >> $GITHUB_ENV
- name: Install dart-sass-embedded MacOS
curl -LJO "https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-linux-arm64.tar.gz";
tar -xvf "dart-sass-${SASS_VERSION}-linux-arm64.tar.gz";
echo "DART_SASS_BINARY=$GITHUB_WORKSPACE/dart-sass/sass" >> $GITHUB_ENV
./dart-sass/sass --version
- name: Install dart-sass MacOS
if: matrix.os == 'macos-latest'
run: |
curl -LJO "https://github.com/sass/dart-sass-embedded/releases/download/${DART_SASS_VERSION}/sass_embedded-${DART_SASS_VERSION}-macos-x64.tar.gz";
tar -xvf "sass_embedded-${DART_SASS_VERSION}-macos-x64.tar.gz";
echo "DART_SASS_EMBEDDED_BINARY=$GITHUB_WORKSPACE/sass_embedded/dart-sass-embedded" >> $GITHUB_ENV
- name: Install dart-sass-embedded Windows
curl -LJO https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-macos-x64.tar.gz";
tar -xvf "dart-sass-${SASS_VERSION}-macos-x64.tar.gz";
echo "DART_SASS_BINARY=$GITHUB_WORKSPACE/dart-sass/sass" >> $GITHUB_ENV
- name: Install dart-sass Windows
if: matrix.os == 'windows-latest'
run: |
curl -LJO "https://github.com/sass/dart-sass-embedded/releases/download/${env:DART_SASS_VERSION}/sass_embedded-${env:DART_SASS_VERSION}-windows-x64.zip";
Expand-Archive -Path "sass_embedded-${env:DART_SASS_VERSION}-windows-x64.zip" -DestinationPath .;
echo "DART_SASS_EMBEDDED_BINARY=$env:GITHUB_WORKSPACE/sass_embedded/dart-sass-embedded.bat" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
curl -LJO "https://github.com/sass/dart-sass/releases/download/${SASS_VERSION}/dart-sass-${SASS_VERSION}-windows-x64.zip";
Expand-Archive -Path "dart-sass-${env:SASS_VERSION}-windows-x64.zip" -DestinationPath .;
echo "DART_SASS_BINARY=$env:GITHUB_WORKSPACE/dart-sass/sass.bat" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Test
run: go test -race . -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage
Expand Down
4 changes: 2 additions & 2 deletions internal/embeddedsass/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

* Install protobuf: https://github.com/protocolbuffers/protobuf
* Install the Go plugin: go get -u google.golang.org/protobuf/cmd/protoc-gen-go
* Download the correct version of the proto file: https://github.com/sass/embedded-protocol/blob/master/embedded_sass.proto
* Install the Go plugin: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
* Download the correct version of the proto file: https://github.com/sass/sass/blob/main/spec/embedded_sass.proto
* protoc --go_opt=Membedded_sass.proto=github.com/bep/godartsass/internal/embeddedsass --go_opt=paths=source_relative --go_out=. embedded_sass.proto
Loading

0 comments on commit c47c03e

Please sign in to comment.