class SvelteOnRails::Lib::Utils
def self.watch_changes_and_precompile
def self.watch_changes_and_precompile config = SvelteOnRails::Configuration.instance return unless config.watch_changes? mtime = Dir[File.join(config.components_folder_full, '**/*.svelte')].map do |file| File.mtime(file).to_f end.max || 0.0 last = if Dir.exist?(config.ssr_dist_folder) mtime_path = config.ssr_dist_folder.join('last_mtime') (File.exist?(mtime_path) ? File.read(mtime_path).to_f : 0.0) end if !last || mtime > last precompile(mtime) end end