Module: Snails::Assets::Tasks

Defined in:
lib/snails/app.rb

Class Method Summary collapse

Class Method Details

.precompile_for(app) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/snails/app.rb', line 159

def self.precompile_for(app)
  unless app.respond_to?(:assets_public_path)
    return puts "#{app.name} doesn't have the Asset module included."
  end

  puts "Precompiling #{app.name} assets to #{app.assets_public_path}..."
  FileUtils.remove_dir(app.assets_public_path.to_s, true)

  environment = app.sprockets
  manifest    = ::Sprockets::Manifest.new(environment.index, app.assets_public_path)
  manifest.compile(app.assets_precompile)

  if app.assets_remove_digests?
    # files = Dir[app.assets_public_path.to_s + '/*/*']
    files = `find #{app.assets_public_path}`.split("\n").select { |f| f[/\.(js|css)/] }
    remove_digests(files)
  end
end