Class: BridgetownSasso::Builder
- Inherits:
-
Bridgetown::Builder
- Object
- Bridgetown::Builder
- BridgetownSasso::Builder
- Defined in:
- lib/bridgetown-sasso/builder.rb
Overview
Compiles the configured SCSS entrypoints with the pure-Rust ‘sasso` compiler after each build and writes the resulting CSS into the site’s output directory. Runs in-process — no Node, no Dart, no subprocess.
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/bridgetown-sasso/builder.rb', line 11 def build # Compile after the site is written, so the CSS lands in the output dir # (and survives that build's cleanup); a watch rebuild regenerates it. hook :site, :post_write do compile_all end end |
#compile_all ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bridgetown-sasso/builder.rb', line 19 def compile_all style = resolved_style Array(entrypoints).each do |source, output| src = site.in_source_dir(styles_dir, source.to_s) unless File.file?(src) Bridgetown.logger.warn("bridgetown-sasso:", "entrypoint not found: #{src}") next end # `Sasso.compile` already searches the entry file's own directory for # relative `@use`/`@import`; `load_paths` adds any extra dirs. css = ::Sasso.compile(src, style: style, load_paths: extra_load_paths) dest = site.in_dest_dir(output.to_s) FileUtils.mkdir_p(File.dirname(dest)) File.write(dest, css) Bridgetown.logger.info("bridgetown-sasso:", "#{source} -> #{output} (#{style})") end end |