nickjj/manifest-revision-webpack-plugin

Calling other formatters

REBELinBLUE opened this issue · 3 comments

Hi,

Sorry if this is really obvious but is there a way to all other formatters for a custom formatter? Basically I am looking at formatting the manifest for Laravel elixir (which I believe uses gulp-rev) and it is almost exactly the same as the "general" formatter, just that instead of

{
    "assets": {
        "file.js": "file.hash.js"
    }
}

it is simply

{
    "file.js": "file.hash.js"
}

i.e. the "assets" key is the top level.

So it seems that really my custom formatter just needs to call the general formatter and then just return the assets key

Sorry, I'm an idiot. Literally as soon as I asked I realised

const Formatter = require('manifest-revision-webpack-plugin/format');
const elixirFormatter = function (data, parsedAssets) {
  const format = new Formatter(data, parsedAssets);
  const outputData = format.general();

  return outputData.assets;
};

No worries. If you want to open a PR (along with a test and proper documentation updates), I'll accept it so that there's built in support for Laravel.

👍 I'll see if I have time this evening :)