Skip to content

Conversation

@emmadesilva
Copy link
Member

@emmadesilva emmadesilva commented Sep 6, 2022

About

Adds a silent (as it takes less than 1ms) post-build task to generate a simple JSON manifest of the MD5 hashes of the source file and the compiled HTML file. This can then be used to see if a page needs to be recompiled. MD5 was chosen for its speed and size and I think it's fine for this use since it's not used for anything cryptographic.

Usage scenarion

This can be used to determine if a compiled page is up to date with the source file by comparing if the input and output hashes match.

Configuration

The feature can be disabled in the configuration, as can output path. The defaults are seen below. They are not in the default config file, instead these are simply the fallback values internally.

// config/hyde.php
'generate_build_manifest' => true,
'build_manifest_path' => 'storage/framework/cache/build-manifest.json',

Example output

Here's the output for the base install, with formatted JSON

[
  {
    "page": "_pages/404.blade.php",
    "input_hash": "7b547049190f6f1ce70dceddab794326",
    "output_hash": "968d221de7edfb39bfdcb4ffda9dbb0e"
  },
  {
    "page": "_pages/index.blade.php",
    "input_hash": "05e29782724141145bc81bc7bba6024c",
    "output_hash": "6d92038753099941300ace4340e0cc97"
  }
]

@emmadesilva emmadesilva marked this pull request as ready for review September 6, 2022 09:55
@emmadesilva emmadesilva merged commit e9ecc57 into master Sep 6, 2022
@emmadesilva emmadesilva deleted the build-manifest branch September 6, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants