Sha256: e4166fa7834d7182a39f30a2e8ff01d05bc0fa60694226d4f50411ddf50be63a

Contents?: true

Size: 1.04 KB

Versions: 74

Compression:

Stored size: 1.04 KB

Contents

namespace :js do

  desc "Compile the JS for Rails apps without Asset Pipeline"
  task :compile do
    require 'sprockets'
    require 'uglifier'
    require 'fileutils'

    root_dir = File.expand_path(File.join("..", ".."), __FILE__)
    js_dir = File.join(root_dir, "app", "assets", "javascripts", "active_admin")
    generated_file = File.join(root_dir, 'lib', 'generators', 'active_admin', 'assets', 'templates', '3.0', 'active_admin.js')

    # The base.js file requires jquery. We don't need jquery to
    # compile the assets, however Sprockets will try to look it up
    # and raise an exception. Insteaad, we move the file out of the directory
    # then put it back after we compile.
    base_js = File.join(js_dir, "base.js")
    tmp_base_js = File.join(root_dir, "base.js")
    FileUtils.mv base_js, tmp_base_js

    env = Sprockets::Environment.new
    env.js_compressor = ::Uglifier.new
    env.append_path js_dir

    File.open generated_file, "w+" do |f|
      f << env["application"]
    end

    FileUtils.mv tmp_base_js, base_js
  end

end

Version data entries

74 entries across 74 versions & 7 rubygems

Version Path
activeadmin-mongoid-0.3.0 tasks/js.rake
activeadmin-0.6.1 tasks/js.rake
aa-rails4-0.6.0 tasks/js.rake
activeadmin-mongoid-0.2.0 tasks/js.rake
lalala-4.0.0.dev.141 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.136 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.135 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.134 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.133 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.132 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.131 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.129 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.128 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.126 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.125 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.124 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.123 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.118 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.116 vendor/deps/active_admin/tasks/js.rake
lalala-4.0.0.dev.114 vendor/deps/active_admin/tasks/js.rake