#!/usr/bin/env ruby ENV['RACK_ENV'] = 'production' if ARGV[0] == 'help' puts 'lux assets rm gzip s3://assets' puts ' rm - remove local cached folder for assets' puts ' gzip - gzip files (for nginx)' puts ' s3://path - copy files to bucket (must be last argument)' exit end if ARGV.include?('rm') system 'rm -rf ./tmp/assets' system 'rm -rf ./public/assets' end require './config/application' assets = Dir['./app/assets/**/index.*'].map { |el| el.sub('./app/assets/','') } Lux.config.assets_precompile = true speed = Lux.speed do # tpool is not showing compile errors # tpool(assets) do |file| for file in assets assets = MiniAssets.new file # asset = MiniAsset.create file # asset.compile ARGV puts "Generated #{file.green} -> #{assets.render}" end end puts "Asset precomlile done in #{speed}" if ARGV.last && ARGV.last[0,5] == 's3://' puts 'Copy to %s'.green % ARGV.last system 'aws s3 sync ./public %s --cache-control "max-age=31536000, no-transform, public"' % ARGV.last end