Maintenance: Load asset processing gems only at build time.

This commit is contained in:
Martin Gruner 2021-07-12 11:46:57 +02:00 committed by Thorsten Eckel
parent 6145fb93f8
commit 3fae5a027f
3 changed files with 25 additions and 14 deletions

23
Gemfile
View file

@ -47,24 +47,27 @@ gem 'rszr', '0.5.2'
# performance - Memcached # performance - Memcached
gem 'dalli', require: false gem 'dalli', require: false
# Only load gems for asset compilation if they are needed to avoid
# having unneeded runtime dependencies like NodeJS.
group :assets do
# asset handling - javascript execution for e.g. linux
gem 'execjs', require: false
# asset handling - coffee-script # asset handling - coffee-script
gem 'coffee-rails' gem 'coffee-rails', require: false
gem 'coffee-script-source'
# asset handling - frontend templating # asset handling - frontend templating
gem 'eco' gem 'eco', require: false
# asset handling - SASS # asset handling - SASS
gem 'sassc-rails' gem 'sassc-rails', require: false
# asset handling - pipeline # asset handling - pipeline
gem 'sprockets', '~> 3.7.2' gem 'sprockets', '~> 3.7.2', require: false
gem 'uglifier' gem 'uglifier', require: false
gem 'autoprefixer-rails' gem 'autoprefixer-rails', require: false
end
# asset handling - javascript execution for e.g. linux
gem 'execjs'
# Don't use mini_racer any more for asset compilation. # Don't use mini_racer any more for asset compilation.
# Instead, use an external node.js binary. # Instead, use an external node.js binary.

View file

@ -5,7 +5,7 @@ module ApplicationController::HandlesErrors
included do included do
rescue_from StandardError, with: :internal_server_error rescue_from StandardError, with: :internal_server_error
rescue_from ExecJS::RuntimeError, with: :internal_server_error rescue_from 'ExecJS::RuntimeError', with: :internal_server_error
rescue_from ActiveRecord::RecordNotFound, with: :not_found rescue_from ActiveRecord::RecordNotFound, with: :not_found
rescue_from ActiveRecord::StatementInvalid, with: :unprocessable_entity rescue_from ActiveRecord::StatementInvalid, with: :unprocessable_entity
rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity rescue_from ActiveRecord::RecordInvalid, with: :unprocessable_entity

View file

@ -12,6 +12,14 @@ Bundler.setup
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
# Only load gems for asset compilation if they are needed to avoid
# having unneeded runtime dependencies like NodeJS.
if ARGV.include?('assets:precompile') || Rails.groups.exclude?('production')
Bundler.load.current_dependencies.select do |dep|
require dep.name if dep.groups.include?(:assets)
end
end
module Zammad module Zammad
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.