MCPcopy
hub / github.com/webpack/webpack / handleFile

Method handleFile

lib/ManifestPlugin.js:177–210  ·  view source on GitHub ↗
(file, usedName)

Source from the content-addressed store, hash-verified

175 * @returns {void}
176 */
177 const handleFile = (file, usedName) => {
178 if (added.has(file)) return;
179 added.add(file);
180
181 const asset = compilation.getAsset(file);
182 if (!asset) return;
183 const sourceFilename = asset.info.sourceFilename;
184 const name =
185 usedName ||
186 sourceFilename ||
187 // Fallback for unofficial plugins, just remove hash from filename
188 removeHash(file, asset.info);
189
190 const prefix = (this.options.prefix || DEFAULT_PREFIX).replace(
191 /\[publicpath\]/gi,
192 () => (publicPath === "auto" ? "/" : publicPath)
193 );
194 /** @type {ManifestItem} */
195 const item = { file: prefix + file };
196
197 if (sourceFilename) {
198 item.src = sourceFilename;
199 }
200
201 if (this.options.filter) {
202 const needKeep = this.options.filter(item);
203
204 if (!needKeep) {
205 return;
206 }
207 }
208
209 assets[name] = item;
210 };
211
212 for (const chunk of compilation.chunks) {
213 if (chunk instanceof HotUpdateChunk) continue;

Callers

nothing calls this directly

Calls 4

getAssetMethod · 0.80
hasMethod · 0.45
addMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected