Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit fbc1e5c

Browse files
committed
Remove the requirejs:precompile:disable_js_compressor task and put its functionality in the engine's before_initialize hook
1 parent 714dc9f commit fbc1e5c

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

lib/requirejs/rails/engine.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ class Engine < ::Rails::Engine
2020

2121
config.assets.precompile += config.requirejs.precompile
2222

23+
# Check for the existence of the requirejs:precompile:all top-level Rake task and disable asset pipeline
24+
# compression to ensure that `r.js` gets uncompressed assets.
25+
Rake.application.top_level_tasks.each do |task_name|
26+
case task_name
27+
when "requirejs:precompile:all"
28+
config.assets.js_compressor = false
29+
end
30+
end if defined?(Rake.application)
31+
2332
manifest_directory = config.assets.manifest || File.join(::Rails.public_path, config.assets.prefix)
2433
manifest_path = File.join(manifest_directory, "rjs_manifest.yml")
2534
config.requirejs.manifest_path = Pathname.new(manifest_path)

lib/tasks/requirejs-rails_tasks.rake

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,6 @@ OS X Homebrew users can use 'brew install node'.
7777
"requirejs:precompile:run_rjs",
7878
"requirejs:precompile:digestify_and_compress"]
7979

80-
task :disable_js_compressor do
81-
# Ensure that Sprockets doesn't try to compress assets before they hit
82-
# r.js. Failure to do this can cause a build which works in dev, but
83-
# emits require.js "notloaded" errors, etc. in production.
84-
#
85-
# Note that a configuration block is used here to ensure that it runs
86-
# after the environment ("config/application.rb",
87-
# "config/environments/*.rb") has been set up.
88-
Rails.application.config.assets.configure do |env|
89-
env.js_compressor = false
90-
end
91-
end
92-
9380
# Invoke another ruby process if we're called from inside
9481
# assets:precompile so we don't clobber the environment
9582
#
@@ -160,6 +147,3 @@ OS X Homebrew users can use 'brew install node'.
160147
end
161148

162149
task "assets:precompile" => ["requirejs:precompile:external"]
163-
if ARGV[0] == "requirejs:precompile:all"
164-
task "assets:environment" => ["requirejs:precompile:disable_js_compressor"]
165-
end

0 commit comments

Comments
 (0)