aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/Rakefile
diff options
context:
space:
mode:
authorJavan Makhmali <javan@javan.us>2016-01-30 15:41:14 -0500
committerJon Moss <me@jonathanmoss.me>2016-01-30 20:41:54 -0500
commit896950a605c509f19f3e8cbde11e23ca87036ca3 (patch)
tree7980c40f97772ed8c047b167ca68c21ae2742bb4 /actioncable/Rakefile
parent96355e87cba247246234386b0af9273cc5d59db9 (diff)
downloadrails-896950a605c509f19f3e8cbde11e23ca87036ca3.tar.gz
rails-896950a605c509f19f3e8cbde11e23ca87036ca3.tar.bz2
rails-896950a605c509f19f3e8cbde11e23ca87036ca3.zip
Add task to create precompiled action_cable.js and reorganize to accommodate
Diffstat (limited to 'actioncable/Rakefile')
-rw-r--r--actioncable/Rakefile29
1 files changed, 29 insertions, 0 deletions
diff --git a/actioncable/Rakefile b/actioncable/Rakefile
index b6c56e9195..9ba431f8a9 100644
--- a/actioncable/Rakefile
+++ b/actioncable/Rakefile
@@ -1,4 +1,8 @@
require 'rake/testtask'
+require 'pathname'
+require 'sprockets'
+require 'coffee-script'
+require 'action_cable'
dir = File.dirname(__FILE__)
@@ -11,3 +15,28 @@ Rake::TestTask.new do |t|
t.verbose = true
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
end
+
+namespace :assets do
+ desc "Compile dist/action_cable.js"
+ task :compile do
+ asset_mapping = { "source.js" => "action_cable.js" }
+
+ root_path = Pathname.new(dir)
+ load_path = root_path.join("lib/assets/javascripts/action_cable")
+
+ compile_path = root_path.join("tmp/sprockets")
+ compile_path.rmtree if compile_path.exist?
+ compile_path.mkpath
+
+ environment = Sprockets::Environment.new
+ environment.append_path(load_path)
+
+ manifest = Sprockets::Manifest.new(environment.index, compile_path)
+ manifest.compile(asset_mapping.keys)
+
+ asset_mapping.each do |logical_path, dist_path|
+ fingerprint_path = manifest.assets[logical_path]
+ FileUtils.cp(compile_path.join(fingerprint_path), load_path.join("dist/#{dist_path}"))
+ end
+ end
+end