class Middleman::CriticalCssExtension

Public Instance Methods

after_build() click to toggle source
# File lib/middleman-critical_css/extension.rb, line 10
def after_build
  Dir.glob(html_files) do |file|
    asset_path = File.join(app.root, file)

    file.slice! app.config[:build_dir] + File::SEPARATOR

    `#{cmd(asset_path, file)}`
  end
end
cmd(asset_path, file) click to toggle source
# File lib/middleman-critical_css/extension.rb, line 24
def cmd(asset_path, file)
  args = [
    options.binary,
    asset_path,
    "--base", app.config[:build_dir],
    "--htmlTarget", file,
    "--inline",
    "--width", options.width,
    "--height", options.height,
  ]
  args << "--minify" if options.minify

  args.join(" ")
end
html_files() click to toggle source
# File lib/middleman-critical_css/extension.rb, line 20
def html_files
  File.join(app.config[:build_dir], "**", "*.html")
end