Skip to content

Instantly share code, notes, and snippets.

@ScriptedAlchemy
Created September 2, 2019 19:43
Show Gist options
  • Select an option

  • Save ScriptedAlchemy/f667d4eda6eaa749082e643c88b48663 to your computer and use it in GitHub Desktop.

Select an option

Save ScriptedAlchemy/f667d4eda6eaa749082e643c88b48663 to your computer and use it in GitHub Desktop.
Render Manifest Webpack Plugin
compilation.mainTemplate.hooks.renderManifest.tap(
'URLImportPlugin',
(result, { chunk }) => {
console.log(chunk);
const renderedModules = Array.from(chunk.modulesIterable).filter(
(module) => module.type === MODULE_TYPE
);
if (renderedModules.length > 0) {
result.push({
render: () =>
this.renderContentAsset(
compilation,
chunk,
renderedModules,
compilation.runtimeTemplate.requestShortener
),
filenameTemplate: ({ chunk: chunkData }) =>
this.options.moduleFilename(chunkData),
pathOptions: {
chunk,
contentHashType: MODULE_TYPE,
},
identifier: `${pluginName}.${chunk.id}`,
hash: chunk.contentHash[MODULE_TYPE],
});
}
},
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment