diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-01 05:02:42 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-02-01 05:02:48 +1030 |
commit | ca9603fc35d123d1c8490096dc0447a91f3e3c18 (patch) | |
tree | ad4e5447995a27fa3c2d522210f146065420a7b4 /actioncable/Rakefile | |
parent | b7a6dc91bcba1382f05f0b510570be98a508f63c (diff) | |
parent | cb040aa0e54b8659c895cff3bf7302716f2b81ed (diff) | |
download | rails-ca9603fc35d123d1c8490096dc0447a91f3e3c18.tar.gz rails-ca9603fc35d123d1c8490096dc0447a91f3e3c18.tar.bz2 rails-ca9603fc35d123d1c8490096dc0447a91f3e3c18.zip |
Merge pull request #23369 from maclover7/actioncable-assets-redux
Action Cable Assets Compilation redux
Diffstat (limited to 'actioncable/Rakefile')
-rw-r--r-- | actioncable/Rakefile | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/actioncable/Rakefile b/actioncable/Rakefile index b6c56e9195..0a036e3e3d 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,34 @@ 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 + puts 'Compiling Action Cable assets...' + + asset_mapping = { "source.js" => "action_cable.js" } + + root_path = Pathname.new(dir) + load_path = root_path.join("app/assets/javascripts/action_cable") + destination_path = root_path.join("lib/assets/javascripts") + + 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), destination_path.join(dist_path)) + end + + puts '======' + puts 'Action Cable assets compiled successfully!' + end +end |