module Roda::RodaPlugins::RecheckPrecompiledAssets

def self.configure(app)

def self.configure(app)
  precompiled_file = app.assets_opts[:precompiled]
  prev_mtime = ::File.mtime(precompiled_file)
  app.instance_exec do
    opts[:assets] = opts[:assets].merge(:compiled=>_compiled_assets_initial_hash.replace(assets_opts[:compiled])).freeze
    define_singleton_method(:recheck_precompiled_assets) do
      new_mtime = ::File.mtime(precompiled_file)
      if new_mtime != prev_mtime
        prev_mtime = new_mtime
        assets_opts[:compiled].replace(_precompiled_asset_metadata(precompiled_file))
        # Unset the cached asset matchers, so new ones will be generated.
        # This is needed in case the new precompiled metadata uses
        # different files.
        app::RodaRequest.instance_variable_set(:@assets_matchers, nil)
      end
    end
    singleton_class.send(:alias_method, :recheck_precompiled_assets, :recheck_precompiled_assets)
  end
end