Skip to content

Instantly share code, notes, and snippets.

@Chocksy
Created September 7, 2016 11:40
Show Gist options
  • Save Chocksy/1155882a21d5de608b5295febc4584f3 to your computer and use it in GitHub Desktop.
Save Chocksy/1155882a21d5de608b5295febc4584f3 to your computer and use it in GitHub Desktop.
Precompile js files in rails
# use this file in the rails app root directory and run it with
# ruby precompile_assets.rb to see if there is any error in your
# js file assets by using Uglifier. This would save you from running
# rake assets:precompile and using production as env var.
require './config/environment'
JS_PATH = 'app/assets/javascripts/**/*.js'.freeze
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment