class Lookbook::Engine
def component_paths
def component_paths @component_paths ||= begin paths = [*config.lookbook.component_paths, *view_paths, host_app_path] Utils.normalize_paths(paths) end end
def enabled?
def enabled? config.lookbook.enabled end
def files_updated!
def files_updated! @updated_at = DateTime.now end
def host_app_path
def host_app_path Rails.application.root.join("app") end
def mount_path
def mount_path config.lookbook.mount_path || Lookbook::Config.defaults.mount_path end
def notifications
def notifications @notifications ||= Notifications.new end
def start
def start raise "Lookbook is already started!" if @started info("Starting Lookbook in #{Lookbook.env} mode...") if watch_files? Reloaders.register(Previews.reloader) Reloaders.register(Pages.reloader) Reloaders.execute else Previews.load Pages.load end @started = true info("Lookbook started#{" - watching filesystem for changes" if watch_files?}") end
def updated_at
def updated_at @updated_at ||= DateTime.now end
def view_paths
def view_paths @view_paths ||= begin # handle view path registry changes in Rails 7.1 paths = if defined?(ActionView::PathRegistry) ActionView::PathRegistry.all_file_system_resolvers.map(&:path) else ActionView::ViewPaths.all_view_paths.flat_map(&paths) end Utils.normalize_paths(paths.map(&:to_s)) end end
def watch_files?
def watch_files? config.lookbook.reload_on_change end