Blame SOURCES/recompile_js.rb

f241b6
f241b6
require 'pathname'
f241b6
require 'sprockets'
f241b6
require 'coffee-script'
f241b6
require 'action_cable'
f241b6
f241b6
dir = File.dirname(__FILE__)
f241b6
f241b6
root_path = Pathname.new(dir)
f241b6
destination_path = root_path.join("lib/assets/compiled")
f241b6
f241b6
puts 'Compiling Action Cable assets...'
f241b6
f241b6
precompile_list = %w(action_cable.js)
f241b6
f241b6
environment = Sprockets::Environment.new
f241b6
f241b6
environment.gzip = false
f241b6
Pathname.glob(root_path.join("app/assets/*/")) do |subdir|
f241b6
  environment.append_path subdir
f241b6
end
f241b6
f241b6
compile_path = root_path.join("tmp/sprockets")
f241b6
compile_path.rmtree if compile_path.exist?
f241b6
compile_path.mkpath
f241b6
f241b6
manifest = Sprockets::Manifest.new(environment.index, compile_path)
f241b6
manifest.compile(precompile_list)
f241b6
f241b6
destination_path.rmtree if destination_path.exist?
f241b6
f241b6
manifest.assets.each do |path, fingerprint_path|
f241b6
  destination_path.join(path).dirname.mkpath
f241b6
  FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(path))
f241b6
end
f241b6
f241b6
puts 'Done'