Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 6

## main

* Fix setting custom `preview_paths`.

*Thomas von Deyen*

* Introduce component-local config and migrate `strip_trailing_whitespace` to use it under the hood.

*Simon Fish*
Expand Down
6 changes: 3 additions & 3 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class Engine < Rails::Engine # :nodoc:
end
# :nocov:

initializer "view_component.set_autoload_paths" do |app|
initializer "view_component.set_autoload_paths", before: :set_autoload_paths do |app|
options = app.config.view_component

if options.show_previews && !options.preview_paths.empty?
paths_to_add = options.preview_paths - ActiveSupport::Dependencies.autoload_paths
ActiveSupport::Dependencies.autoload_paths.concat(paths_to_add) if paths_to_add.any?
paths_to_add = options.preview_paths - app.config.autoload_paths
app.config.autoload_paths.concat(paths_to_add) if paths_to_add.any?
end
end

Expand Down
Loading