diff --git a/lib/manageiq/ui/classic/engine.rb b/lib/manageiq/ui/classic/engine.rb index b3a55c477a4..cd957b42932 100644 --- a/lib/manageiq/ui/classic/engine.rb +++ b/lib/manageiq/ui/classic/engine.rb @@ -37,10 +37,15 @@ class Engine < ::Rails::Engine config.assets.paths << root.join('vendor', 'assets', 'stylesheets').to_s if Rails.env.production? || Rails.env.test? - # Workaround rails 7 + es6 syntax in some js causing uglifier errors by running harmony mode - # See: https://www.github.com/lautis/uglifier/issues/127 - require 'uglifier' - config.assets.js_compressor = Uglifier.new(:harmony => true) + config.assets.configure do |env| + # Workaround rails 7 + es6 syntax in some js causing uglifier errors by running harmony mode + # See: https://www.github.com/lautis/uglifier/issues/127 + # Note, we're purposely using our own compressor to avoid requiring uglifier at application boot time + # since this require a js runtime such as node. + require 'manageiq/ui/classic/js_compressor' + env.register_compressor 'application/javascript', :manageiq_ui_classic_js_compressor, ManageIQ::UI::Classic::JsCompressor + end + config.assets.js_compressor = :manageiq_ui_classic_js_compressor end def self.vmdb_plugin? diff --git a/lib/manageiq/ui/classic/js_compressor.rb b/lib/manageiq/ui/classic/js_compressor.rb new file mode 100644 index 00000000000..91a002c57a5 --- /dev/null +++ b/lib/manageiq/ui/classic/js_compressor.rb @@ -0,0 +1,13 @@ +module ManageIQ + module UI + module Classic + class JsCompressor < Sprockets::UglifierCompressor + def initialize(options = {}) + warn "\e[33m** Using #{self.class.name} with Uglifier.new(:harmony => true) from: #{__FILE__}:#{__LINE__}\e[0m" + options[:harmony] = true + super(options) + end + end + end + end +end