module ReactOnRails def self.configure yield(configuration) end DEFAULT_GENERATED_ASSETS_DIRS = [ %w(app assets webpack) ].map { |dirs| File.join(*dirs) }.freeze def self.configuration @configuration ||= Configuration.new( generated_assets_dirs: DEFAULT_GENERATED_ASSETS_DIRS, server_bundle_js_file: "", prerender: false, replay_console: true, logging_on_server: true, raise_on_prerender_error: false, trace: Rails.env.development?, development_mode: Rails.env.development?, server_renderer_pool_size: 1, server_renderer_timeout: 20, skip_display_none: false) end class Configuration attr_accessor :server_bundle_js_file, :prerender, :replay_console, :trace, :development_mode, :logging_on_server, :server_renderer_pool_size, :server_renderer_timeout, :raise_on_prerender_error, :skip_display_none, :generated_assets_dirs def initialize(server_bundle_js_file: nil, prerender: nil, replay_console: nil, trace: nil, development_mode: nil, logging_on_server: nil, server_renderer_pool_size: nil, server_renderer_timeout: nil, raise_on_prerender_error: nil, skip_display_none: nil, generated_assets_dirs: DEFAULT_GENERATED_ASSETS_DIRS) self.server_bundle_js_file = if File.exist?(server_bundle_js_file) server_bundle_js_file end self.generated_assets_dirs = generated_assets_dirs self.prerender = prerender self.replay_console = replay_console self.logging_on_server = logging_on_server self.development_mode = if development_mode.nil? Rails.env.development? else development_mode end self.trace = trace.nil? ? Rails.env.development? : trace self.raise_on_prerender_error = raise_on_prerender_error self.skip_display_none = skip_display_none # Server rendering: self.server_renderer_pool_size = self.development_mode ? 1 : server_renderer_pool_size self.server_renderer_timeout = server_renderer_timeout # seconds end end end