Module: Qbuild::StylesheetHandler

Defined in:
lib/qbuild/stylesheet_handler.rb

Class Method Summary collapse

Class Method Details

.scss_to_css(content) ⇒ Object



23
24
25
26
27
28
# File 'lib/qbuild/stylesheet_handler.rb', line 23

def self.scss_to_css(content)
  sass_engine = Sass::Engine.new(content, style: :compressed,
                                          syntax: :scss,
                                          cache: false)
  sass_engine.render
end

.transpile_and_minify_styleObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/qbuild/stylesheet_handler.rb', line 6

def self.transpile_and_minify_style
  style_formats = ['.css', '.scss']
  style_filenames = Qbuild::Config.stylesheet_filenames
  min_style_path = Qbuild::Config.minified_stylesheets_path
  min_style_file = Qbuild::Config.stylesheet_name
  Qbuild::Config.create_target_directory(min_style_path)
  content = ''
  style_filenames.each do |file|
    next unless PadUtils.file_exist?(file)
    next unless style_formats.include? File.extname(file)
    next if file.include? '.min.css'
    content += "\n#{File.read(file)}"
  end
  minified = scss_to_css content
  File.write("#{min_style_path}/#{min_style_file}", minified)
end