Skip to content

Commit

Permalink
Only run yarn:install before assets:precompile if bin/yarn present
Browse files Browse the repository at this point in the history
Based on discussion in rails#40795, it
looks like `yarn:install` is *always* run, even if the Rails project
disabled javascript and there is no `bin/yarn`.

Check for the existence of `bin/yarn` to decide if `yarn:install` should
be run or not.

The check for this is taken from `railties/lib/rails/app_updater.rb`,
where it does the same:

```ruby
         options[:skip_javascript] = !File.exist?(Rails.root.join("bin", "yarn"))
```
  • Loading branch information
doits committed Dec 11, 2020
1 parent 0180128 commit 87e9ae0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/tasks/yarn.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ namespace :yarn do
end

# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
if Rake::Task.task_defined?("assets:precompile")
if Rake::Task.task_defined?("assets:precompile") && File.exist?(Rails.root.join("bin", "yarn"))
Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
end

0 comments on commit 87e9ae0

Please sign in to comment.