bridgetown-sasso 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b68b631ae279627da6312ca719e9748b5715bef5ef7e6ddb67919f85a90dd8cd
4
+ data.tar.gz: 4d63762884c2fe576e18ed29203cfc3062f7d2457b8fabb3806320e1461f4335
5
+ SHA512:
6
+ metadata.gz: 1c3a1e478fe0f6d5f43e0bebf684508b15e97995c9b947b659e6fccffc6bc1846b85e2da6ebed46f6d11852bea77b8c2e03c5f2d107d2bd7ddb65df4c9e67c01
7
+ data.tar.gz: e7954ee3a5db6241ee6ac8d9628a1c50d619b7d66a3b85c10dcb20099cdb9ae223b1131500bf06b2db5a598919dbe83afc948e3b6cbbceef63a678c6a41054ae
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to **bridgetown-sasso** are documented here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.1.0] - 2026-06-14
9
+
10
+ Initial release. Requires the `sasso` gem **>= 0.2.0** and Bridgetown **>= 2.0**.
11
+
12
+ ### Added
13
+
14
+ - Bridgetown plugin that compiles configured Sass/SCSS entrypoints with the
15
+ pure-Rust `sasso` compiler in-process (no Node, no Dart, no subprocess) and
16
+ writes the CSS into the site output.
17
+ - Enable with `init :"bridgetown-sasso"`; configure `entrypoints`, `styles_dir`,
18
+ `style`, and `load_paths`.
19
+ - `bridgetown.automation.rb` for `bin/bridgetown apply`.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 momiji-rs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # bridgetown-sasso
2
+
3
+ Compile **Sass/SCSS in [Bridgetown](https://www.bridgetownrb.com)** with
4
+ [**sasso**](https://github.com/momiji-rs/sasso-ruby) — a pure-Rust,
5
+ zero-dependency, byte-for-byte [dart-sass](https://sass-lang.com) alternative.
6
+
7
+ Compilation runs **in-process during the build** — no Node toolchain, no Dart
8
+ VM, no subprocess. Bridgetown's default frontend has no native Sass step; this
9
+ plugin gives you one without pulling in `node` + esbuild + the `sass` npm.
10
+
11
+ - **No Node.** Compile Sass with zero JavaScript tooling.
12
+ - **In-process.** No process spawn per build — sasso is a native Ruby gem.
13
+ - **Byte-for-byte dart-sass.** Same CSS as `dart-sass`, just faster.
14
+
15
+ ## Installation
16
+
17
+ ```ruby
18
+ # Gemfile
19
+ gem "bridgetown-sasso"
20
+ ```
21
+
22
+ ```sh
23
+ bundle install
24
+ ```
25
+
26
+ Then enable it in `config/initializers.rb`:
27
+
28
+ ```ruby
29
+ Bridgetown.configure do |config|
30
+ init :"bridgetown-sasso"
31
+ end
32
+ ```
33
+
34
+ Put your entrypoint (and its partials) under `src/_css/` — the leading
35
+ underscore keeps Bridgetown from publishing the raw `.scss`. The default
36
+ entrypoint is `src/_css/index.scss`, compiled to `output/css/main.css`. Link it
37
+ from your layout:
38
+
39
+ ```html
40
+ <link rel="stylesheet" href="/css/main.css">
41
+ ```
42
+
43
+ Or scaffold everything in one step:
44
+
45
+ ```sh
46
+ bin/bridgetown apply https://github.com/momiji-rs/bridgetown-sasso
47
+ ```
48
+
49
+ ## Configuration
50
+
51
+ All optional (defaults shown):
52
+
53
+ ```ruby
54
+ init :"bridgetown-sasso" do
55
+ # <source under src/<styles_dir>> => <output under the site output dir>
56
+ entrypoints({ "index.scss" => "css/main.css" })
57
+
58
+ # Dir under src/ holding the entrypoints + their partials. Underscore-prefixed
59
+ # so Bridgetown does not publish the raw .scss.
60
+ styles_dir "_css"
61
+
62
+ # nil = :compressed in production (BRIDGETOWN_ENV=production), :expanded else.
63
+ # Or force :expanded / :compressed.
64
+ style nil
65
+
66
+ # Extra @use/@import dirs. The entrypoint's own directory is always searched
67
+ # first, so sibling partials (e.g. _buttons.scss) need no configuration.
68
+ load_paths []
69
+ end
70
+ ```
71
+
72
+ Multiple entrypoints are supported — list each one:
73
+
74
+ ```ruby
75
+ entrypoints({ "index.scss" => "css/main.css", "admin.scss" => "css/admin.css" })
76
+ ```
77
+
78
+ ## Performance
79
+
80
+ `sasso` compiles the same CSS as dart-sass, byte-for-byte, but much faster — and
81
+ without any Node runtime. Benchmarked on an Apple M2 Max, all engines dart-sass
82
+ 1.101, against the Node frontend's default Sass engine (`sass`, dart2js):
83
+
84
+ **In-process** (how this plugin compiles — inside the Ruby build process):
85
+
86
+ | workload | bridgetown-sasso | Node `sass` (dart2js) |
87
+ |----------|------------------|-----------------------|
88
+ | ~360 rules | **1.2 ms** | 8.0 ms (**6.4× slower**) |
89
+ | ~3000 rules | **9.9 ms** | 71.5 ms (**7.2× slower**) |
90
+
91
+ **Cold per-build** (a one-shot `bridgetown build` / deploy, including runtime
92
+ startup):
93
+
94
+ | workload | bridgetown-sasso | dart-sass (native) | Node `sass` (dart2js) |
95
+ |----------|------------------|--------------------|-----------------------|
96
+ | ~360 rules | **3.0 ms** | 27.5 ms (9×) | 185 ms (**63× slower**) |
97
+ | ~3000 rules | **10.9 ms** | 64.2 ms (6×) | 348 ms (**32× slower**) |
98
+
99
+ Output is byte-identical to dart-sass, so this is pure speedup with no behavior
100
+ change. (Synthetic workloads exercising variables, nesting, `&`, unit math,
101
+ color functions, and `@at-root`; ratios are the takeaway, absolute numbers are
102
+ machine-specific.)
103
+
104
+ ## How it fits the build
105
+
106
+ The plugin registers a Bridgetown builder that, after each build, compiles every
107
+ configured entrypoint with `Sasso.compile` and writes the CSS into the site
108
+ output directory. `bin/bridgetown build` and `bridgetown serve` (watch) both
109
+ regenerate it. Because the CSS is produced in-process, there is no Node
110
+ dependency for Sass at all.
111
+
112
+ ## License
113
+
114
+ MIT, matching the Sass ecosystem. (The core `sasso` compiler crate is dual
115
+ MIT OR Apache-2.0.)
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test" << "lib"
8
+ t.test_files = FileList["test/**/test_*.rb"]
9
+ t.warning = false
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bridgetown-sasso/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bridgetown-sasso"
7
+ spec.version = BridgetownSasso::VERSION
8
+ spec.author = "momiji-rs"
9
+ spec.summary = "Compile Sass/SCSS in Bridgetown with the pure-Rust sasso compiler — no Node, no Dart"
10
+ spec.description = "A Bridgetown plugin that compiles your Sass/SCSS entrypoints with sasso, a " \
11
+ "pure-Rust, zero-dependency, byte-for-byte dart-sass alternative. Compilation " \
12
+ "runs in-process during the build (no Node toolchain, no Dart VM, no subprocess)."
13
+ spec.homepage = "https://github.com/momiji-rs/bridgetown-sasso"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata = {
17
+ "homepage_uri" => spec.homepage,
18
+ "source_code_uri" => spec.homepage,
19
+ "changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md",
20
+ "rubygems_mfa_required" => "true",
21
+ }
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|script|spec|features)/}) || f.match(%r{^\.})
25
+ end
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.required_ruby_version = ">= 3.1.0"
29
+
30
+ spec.add_dependency "bridgetown", ">= 2.0"
31
+ spec.add_dependency "sasso", ">= 0.2.0", "< 1"
32
+
33
+ spec.add_development_dependency "bundler"
34
+ spec.add_development_dependency "minitest", "~> 5.0"
35
+ spec.add_development_dependency "minitest-reporters", "~> 1.0"
36
+ spec.add_development_dependency "rake", ">= 13.0"
37
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run with: bin/bridgetown apply https://github.com/momiji-rs/bridgetown-sasso
4
+ #
5
+ # Adds the gem, registers the initializer, and scaffolds a starter entrypoint.
6
+
7
+ add_gem "bridgetown-sasso"
8
+
9
+ add_initializer :"bridgetown-sasso" do
10
+ <<~RUBY
11
+ do
12
+ # entrypoints({ "index.scss" => "css/main.css" })
13
+ # style :compressed # default: :compressed in production, :expanded else
14
+ # load_paths []
15
+ end
16
+ RUBY
17
+ end
18
+
19
+ create_file "src/_css/index.scss" do
20
+ <<~SCSS
21
+ @use "sass:color";
22
+
23
+ $brand: #3366cc;
24
+
25
+ body {
26
+ color: $brand;
27
+ a { color: color.adjust($brand, $lightness: -10%); }
28
+ }
29
+ SCSS
30
+ end
31
+
32
+ say_status :bridgetown_sasso,
33
+ %(Link the compiled CSS in your layout: <link rel="stylesheet" href="/css/main.css">, then `bin/bridgetown build`.),
34
+ :green
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "sasso"
5
+
6
+ module BridgetownSasso
7
+ # Compiles the configured SCSS entrypoints with the pure-Rust `sasso` compiler
8
+ # after each build and writes the resulting CSS into the site's output
9
+ # directory. Runs in-process — no Node, no Dart, no subprocess.
10
+ class Builder < Bridgetown::Builder
11
+ def build
12
+ # Compile after the site is written, so the CSS lands in the output dir
13
+ # (and survives that build's cleanup); a watch rebuild regenerates it.
14
+ hook :site, :post_write do
15
+ compile_all
16
+ end
17
+ end
18
+
19
+ def compile_all
20
+ style = resolved_style
21
+ Array(entrypoints).each do |source, output|
22
+ src = site.in_source_dir(styles_dir, source.to_s)
23
+ unless File.file?(src)
24
+ Bridgetown.logger.warn("bridgetown-sasso:", "entrypoint not found: #{src}")
25
+ next
26
+ end
27
+ # `Sasso.compile` already searches the entry file's own directory for
28
+ # relative `@use`/`@import`; `load_paths` adds any extra dirs.
29
+ css = ::Sasso.compile(src, style: style, load_paths: extra_load_paths)
30
+ dest = site.in_dest_dir(output.to_s)
31
+ FileUtils.mkdir_p(File.dirname(dest))
32
+ File.write(dest, css)
33
+ Bridgetown.logger.info("bridgetown-sasso:", "#{source} -> #{output} (#{style})")
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ # Bridgetown's resolved config exposes nested values as a plain Hash; read
40
+ # defensively (symbol or string keys) so we don't depend on method access.
41
+ def config
42
+ site.config[:bridgetown_sasso] || site.config["bridgetown_sasso"] || {}
43
+ end
44
+
45
+ def cfg(key, default)
46
+ value = config[key]
47
+ value = config[key.to_s] if value.nil?
48
+ value.nil? ? default : value
49
+ end
50
+
51
+ def entrypoints
52
+ cfg(:entrypoints, { "index.scss" => "css/main.css" })
53
+ end
54
+
55
+ def styles_dir
56
+ cfg(:styles_dir, "_css").to_s
57
+ end
58
+
59
+ def extra_load_paths
60
+ Array(cfg(:load_paths, [])).map(&:to_s)
61
+ end
62
+
63
+ # nil -> :compressed in production, :expanded otherwise; a forced value wins.
64
+ def resolved_style
65
+ forced = cfg(:style, nil)
66
+ return forced.to_sym if forced
67
+
68
+ production? ? :compressed : :expanded
69
+ end
70
+
71
+ def production?
72
+ (ENV["BRIDGETOWN_ENV"] || ENV["RACK_ENV"] || "development").to_s == "production"
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgetownSasso
4
+ # The plugin version floats independently of the `sasso` compiler gem; the
5
+ # gemspec pins the compiler with a range.
6
+ VERSION = "0.1.0"
7
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridgetown"
4
+ require "bridgetown-sasso/version"
5
+ require "bridgetown-sasso/builder"
6
+
7
+ # Bridgetown plugin: compile Sass/SCSS with the pure-Rust, zero-dependency
8
+ # `sasso` compiler (a byte-for-byte dart-sass alternative) — no Node, no Dart,
9
+ # no subprocess; compilation happens in-process during the Bridgetown build.
10
+ #
11
+ # Enable it from a site's `config/initializers.rb`:
12
+ #
13
+ # Bridgetown.configure do |config|
14
+ # init :"bridgetown-sasso"
15
+ # end
16
+ #
17
+ # and configure (all optional; defaults shown):
18
+ #
19
+ # init :"bridgetown-sasso" do
20
+ # # entrypoints: <source under source_dir/styles_dir> => <output under dest>
21
+ # entrypoints({ "index.scss" => "css/main.css" })
22
+ # styles_dir "_css" # holds the entrypoints + their partials (underscore =
23
+ # # not published by Bridgetown as raw files)
24
+ # style nil # nil = :compressed in production, :expanded otherwise;
25
+ # # or force :expanded / :compressed
26
+ # load_paths [] # extra @use/@import dirs (the entrypoint's own dir is
27
+ # # always searched first)
28
+ # end
29
+ Bridgetown.initializer :"bridgetown-sasso" do |config|
30
+ config.bridgetown_sasso ||= {}
31
+ config.bridgetown_sasso.entrypoints ||= { "index.scss" => "css/main.css" }
32
+ config.bridgetown_sasso.styles_dir ||= "_css"
33
+ config.bridgetown_sasso.style ||= nil
34
+ config.bridgetown_sasso.load_paths ||= []
35
+
36
+ config.builder BridgetownSasso::Builder
37
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bridgetown-sasso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - momiji-rs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bridgetown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sasso
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '5.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: minitest-reporters
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '13.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '13.0'
103
+ description: A Bridgetown plugin that compiles your Sass/SCSS entrypoints with sasso,
104
+ a pure-Rust, zero-dependency, byte-for-byte dart-sass alternative. Compilation runs
105
+ in-process during the build (no Node toolchain, no Dart VM, no subprocess).
106
+ email:
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - CHANGELOG.md
112
+ - Gemfile
113
+ - LICENSE
114
+ - README.md
115
+ - Rakefile
116
+ - bridgetown-sasso.gemspec
117
+ - bridgetown.automation.rb
118
+ - lib/bridgetown-sasso.rb
119
+ - lib/bridgetown-sasso/builder.rb
120
+ - lib/bridgetown-sasso/version.rb
121
+ homepage: https://github.com/momiji-rs/bridgetown-sasso
122
+ licenses:
123
+ - MIT
124
+ metadata:
125
+ homepage_uri: https://github.com/momiji-rs/bridgetown-sasso
126
+ source_code_uri: https://github.com/momiji-rs/bridgetown-sasso
127
+ changelog_uri: https://github.com/momiji-rs/bridgetown-sasso/blob/main/CHANGELOG.md
128
+ rubygems_mfa_required: 'true'
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 3.1.0
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.5.22
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Compile Sass/SCSS in Bridgetown with the pure-Rust sasso compiler — no Node,
148
+ no Dart
149
+ test_files: []