Module: AlFolioCore::JekyllTerserThemeGuard

Defined in:
lib/al_folio_core.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/al_folio_core.rb', line 81

def generate(site)
  site.static_files.clone.each do |sf|
    next unless sf.kind_of?(Jekyll::StaticFile)
    next unless sf.path =~ /\.js$/
    next if sf.path.end_with?(".min.js")
    next unless AlFolioCore.local_source_asset?(sf.path, site.source)

    puts "Terser: Minifying #{sf.path}"
    site.static_files.delete(sf)
    name = File.basename(sf.path)
    destination = File.dirname(File.expand_path(sf.path)).sub(File.expand_path(site.source), "")
    js_file = Jekyll::Terser::JSFile.new(site, site.source, destination, name, @terser)
    site.static_files << js_file
  end
end