Generate Phoenix's cache manifest via webpack


I’ve been using webpack to generate Phoenix’s cache_manifest.json for a while, and recently started to upgrade to 1.4. I ran into a slight hitch since my manifest doesn’t contain quite everything that phx.digest produces (it only contained the “latest” key). The reason seems to be this change introduced here:

So I’ve fixed the problem it seems by putting in a minimal “digests” key, such that my cache_manifest now looks like:

  "latest": {
    ... snip
    "assets/admin.js": "assets/admin.4215f59c0adf2f5d59bd.js",
  "digests": {
    ... snip
    "assets/admin.4215f59c0adf2f5d59bd.js": {
      "logical_path": "assets/admin.js"

It would be possible to generate the sha512 hash. but can someone help me understand what the sha512 hash is doing for the Phoenix.Config cache? Is it advisable to add this to the cache_manifest?


For reference, here’s how I’m producing the manifest:

    new ManifestPlugin({
      // this is where phoenix looks for the digest manifest
      // (see config/prod.exs)
      fileName: '../cache_manifest.json',

      // phoenix wants these values to be relative file paths
      // if we use the default output.publicPath, phooenix
      // constructs weird URLs
      publicPath: 'assets/',

      generate: (_seed, files) => ({
        // the 'latest' key here is what phoenix looks for:
        latest: files.reduce((latest, {name, path}) => ({
          [`assets/${name}`]: path,
        }), {}),

        // phoenix 1.4 requires 'digests' as well:
        digests: files.reduce((digests, {name, path}) => ({
          [path]: {
            logical_path: `assets/${name}`,
        }), {}),