Module: Bridgetown::Site::FastRefreshable
- Included in:
- Bridgetown::Site
- Defined in:
- bridgetown-core/lib/bridgetown-core/concerns/site/fast_refreshable.rb
Instance Method Summary collapse
-
#fast_refresh(paths = [], reload_if_needed: false) ⇒ Object
rubocop:todo Metrics.
Instance Method Details
#fast_refresh(paths = [], reload_if_needed: false) ⇒ Object
rubocop:todo Metrics
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'bridgetown-core/lib/bridgetown-core/concerns/site/fast_refreshable.rb', line 7 def fast_refresh(paths = [], reload_if_needed: false) # rubocop:todo Metrics FileUtils.rm_f(Bridgetown.build_errors_path) @fast_refresh_ordering = 0 full_abort = false found_gen_pages = false paths.each do |path| # rubocop:todo Metrics found_res = resources.select do |resource| resource.id.start_with?("repo://") && in_source_dir(resource.relative_path) == path end layouts_to_reload = Set.new locate_resource_layouts_and_partials_for_fash_refresh(path, layouts_to_reload) unless found_res.any? locate_components_for_fast_refresh(path) unless found_res.any? pages = locate_layouts_and_pages_for_fast_refresh(path, layouts_to_reload) layouts_to_reload.each do |layout| layouts[layout.label] = Bridgetown::Layout.new( self, layout.instance_variable_get(:@base), layout.name ) end next unless found_res.any? || pages.any? if pages.any? found_gen_pages = true mark_original_page_resources_for_fast_refresh(pages) next end found_res.each do |res| res.prepare_for_fast_refresh!.tap { full_abort = true unless _1 } next unless res.collection.data? res.collection.merge_data_resources.each do |k, v| data[k] = v signals[k] = v end end end marked_resources = resources.select(&:fast_refresh_order).sort_by(&:fast_refresh_order) if full_abort || (marked_resources.empty? && !found_gen_pages) # Darn, a full reload is needed (unless we're on a super-fast track) if reload_if_needed Bridgetown::Hooks.trigger :site, :pre_reload, self, paths Bridgetown::Hooks.clear_reloadable_hooks loaders_manager.reload_loaders Bridgetown::Hooks.trigger :site, :post_reload, self, paths process # bring out the big guns end return end Bridgetown::Hooks.trigger :site, :fast_refresh, self liquid_renderer.reset transform_resources_for_fast_refresh(marked_resources, found_gen_pages) transform_generated_pages_for_fast_refresh FileUtils.touch(in_destination_dir("index.html")) Bridgetown::Hooks.trigger :site, :post_write, self end |