MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/TemplatedPathPlugin.js:737–762  ·  view source on GitHub ↗

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

735 * @returns {void}
736 */
737 apply(compiler) {
738 compiler.hooks.compilation.tap(plugin, (compilation) => {
739 compilation.hooks.assetPath.tap(plugin, (path, data, assetInfo) => {
740 // Default from output options so `[uniqueName]` resolves in every template
741 if (data.uniqueName === undefined) {
742 data.uniqueName = compilation.outputOptions.uniqueName;
743 }
744 // Digest the stored hashes use, so `[hash:<digest>]` can re-encode them
745 if (data.hashDigest === undefined) {
746 data.hashDigest = compilation.outputOptions.hashDigest;
747 }
748 // Untruncated compilation hash, so `[fullhash:<digest>]` keeps full entropy
749 if (data.fullHash === undefined && data.hash === compilation.hash) {
750 data.fullHash = compilation.fullHash;
751 }
752 // `RealContentHashPlugin` rehashes content; flag it so an inline digest
753 // on `[contenthash]` is recorded and the recomputed hash re-encodes in it.
754 if (data.realContentHash === undefined) {
755 data.realContentHash = Boolean(
756 compilation.options.optimization.realContentHash
757 );
758 }
759 return interpolate(path, data, assetInfo);
760 });
761 });
762 }
763}
764
765module.exports = TemplatedPathPlugin;

Callers

nothing calls this directly

Calls 2

interpolateFunction · 0.85
tapMethod · 0.80

Tested by

no test coverage detected