lib/lookbook/engine.rb in lookbook-0.9.2 vs lib/lookbook/engine.rb in lookbook-0.9.3
- old
+ new
@@ -21,10 +21,11 @@
class Engine < Rails::Engine
isolate_namespace Lookbook
config.lookbook = ActiveSupport::OrderedOptions.new
config.lookbook.listen_paths ||= []
+ config.lookbook.listen_extensions ||= []
config.lookbook.preview_paths ||= []
config.lookbook.page_paths ||= ["test/components/docs"]
initializer "view_component.set_configs" do
options = config.lookbook
@@ -53,10 +54,13 @@
options.listen_paths = options.listen_paths.map(&:to_s)
options.listen_paths += options.preview_paths
options.listen_paths << (vc_options.view_component_path || Rails.root.join("app/components"))
options.listen_paths.select! { |path| Dir.exist? path }
+ options.listen_extensions += ["rb", "html.*"]
+ options.listen_extensions.uniq!
+
options.cable_mount_path ||= "/lookbook-cable"
options.cable_logger ||= Rails.logger
options.runtime_parsing = !Rails.env.production? if options.runtime_parsing.nil?
options.parser_registry_path ||= Rails.root.join("tmp/storage/.yardoc")
@@ -78,10 +82,10 @@
config.after_initialize do
@preview_controller = Lookbook.config.preview_controller.constantize
@preview_controller.include(Lookbook::PreviewController)
if config.lookbook.listen
- @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(rb|html.*)$/) do |modified, added, removed|
+ @preview_listener = Listen.to(*config.lookbook.listen_paths, only: /\.(#{config.lookbook.listen_extensions.join("|")})$/) do |modified, added, removed|
begin
parser.parse
rescue
end
Lookbook::Preview.clear_cache