11require 'rake/testtask'
22require 'pathname'
3- require 'sprockets'
4- require 'coffee-script'
53require 'action_cable'
4+ require 'blade'
65
76dir = File . dirname ( __FILE__ )
87
98task :default => :test
109
1110task :package => "assets:compile"
12- task "package:clean" => "assets:clean"
1311
1412Rake ::TestTask . new do |t |
1513 t . libs << "test"
@@ -27,44 +25,13 @@ namespace :test do
2725 end
2826
2927 task :javascript do
30- require 'blade'
3128 Blade . start ( interface : :runner )
3229 end
3330end
3431
3532namespace :assets do
36- root_path = Pathname . new ( dir )
37- destination_path = root_path . join ( "lib/assets/compiled" )
38-
39- desc "Compile dist/action_cable.js"
33+ desc "Compile Action Cable assets"
4034 task :compile do
41- puts 'Compiling Action Cable assets...'
42-
43- precompile_list = %w( action_cable.js )
44-
45- environment = Sprockets ::Environment . new
46- environment . gzip = false
47- Pathname . glob ( root_path . join ( "app/assets/*/" ) ) do |subdir |
48- environment . append_path subdir
49- end
50-
51- compile_path = root_path . join ( "tmp/sprockets" )
52- compile_path . rmtree if compile_path . exist?
53- compile_path . mkpath
54-
55- manifest = Sprockets ::Manifest . new ( environment . index , compile_path )
56- manifest . compile ( precompile_list )
57-
58- destination_path . rmtree if destination_path . exist?
59- manifest . assets . each do |path , fingerprint_path |
60- destination_path . join ( path ) . dirname . mkpath
61- FileUtils . cp ( compile_path . join ( fingerprint_path ) , destination_path . join ( path ) )
62- end
63-
64- puts 'Done'
65- end
66-
67- task :clean do
68- destination_path . rmtree if destination_path . exist?
35+ Blade . build
6936 end
7037end
0 commit comments