forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a rake task to compile js for non Asset Pipeline users
- Loading branch information
Showing
6 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//= require_tree ./lib/ | ||
//= require_tree ./components/ | ||
//= require_tree ./pages/ | ||
//= require_directory ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
lib/generators/active_admin/assets/templates/3.0/active_admin.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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 |