Module: HanamiSasso

Defined in:
lib/hanami-sasso.rb,
lib/hanami-sasso/version.rb,
lib/hanami-sasso/compiler.rb,
lib/hanami-sasso/configuration.rb

Overview

Compile Sass/SCSS in a Hanami app with the pure-Rust ‘sasso` compiler — no Node, no Dart, no subprocess. Provide the rake tasks by requiring “hanami-sasso/rake_tasks” from your Rakefile.

Defined Under Namespace

Classes: Compiler, Configuration

Constant Summary collapse

VERSION =

The plugin version floats independently of the ‘sasso` compiler gem; the gemspec pins the compiler with a range.

"0.1.0"

Class Method Summary collapse

Class Method Details

.compilerObject

Build a Compiler from the current configuration, resolving the env-aware defaults (style + source maps) to concrete values.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hanami-sasso.rb', line 30

def compiler
  c = config
  Compiler.new(
    root:       c.root || Dir.pwd,
    builds:     c.builds,
    style:      c.style || (production? ? :compressed : :expanded),
    load_paths: c.load_paths,
    source_dir: c.source_dir,
    build_dir:  c.build_dir,
    source_map: c.source_map.nil? ? !production? : c.source_map
  )
end

.configObject



12
13
14
# File 'lib/hanami-sasso.rb', line 12

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



16
17
18
# File 'lib/hanami-sasso.rb', line 16

def configure
  yield(config)
end

.production?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hanami-sasso.rb', line 24

def production?
  (ENV["HANAMI_ENV"] || ENV["RACK_ENV"] || "development").to_s == "production"
end

.reset_configuration!Object



20
21
22
# File 'lib/hanami-sasso.rb', line 20

def reset_configuration!
  @config = Configuration.new
end