Module: Dartsass::Runner

Defined in:
lib/dartsass/runner.rb

Constant Summary collapse

EXEC_PATH =
"#{Pathname.new(__dir__).to_s}/../../exe/dartsass"
CSS_LOAD_PATH =
Rails.root.join("app/assets/stylesheets")
CSS_BUILD_PATH =
Rails.root.join("app/assets/builds")

Class Method Summary collapse

Class Method Details

.dartsass_build_mappingObject



9
10
11
12
13
# File 'lib/dartsass/runner.rb', line 9

def dartsass_build_mapping
  Rails.application.config.dartsass.builds.map { |input, output|
    "#{CSS_LOAD_PATH.join(input)}:#{CSS_BUILD_PATH.join(output)}"
  }
end

.dartsass_build_optionsObject



15
16
17
# File 'lib/dartsass/runner.rb', line 15

def dartsass_build_options
  Rails.application.config.dartsass.build_options.flat_map(&:split)
end

.dartsass_compile_commandObject



23
24
25
# File 'lib/dartsass/runner.rb', line 23

def dartsass_compile_command
  [ RbConfig.ruby, EXEC_PATH ].concat(dartsass_build_options).concat(dartsass_load_paths).concat(dartsass_build_mapping)
end

.dartsass_load_pathsObject



19
20
21
# File 'lib/dartsass/runner.rb', line 19

def dartsass_load_paths
  [ CSS_LOAD_PATH ].concat(Rails.application.config.assets.paths).flat_map { |path| ["--load-path", path.to_s] }
end