* Gets asset path with info. * @param {NormalModule} module module for which the code should be generated * @param {Pick<AssetResourceGeneratorOptions, "publicPath">} generatorOptions generator options * @param {GenerateContext} generateContext context for generate * @param {string} filename
(
module,
generatorOptions,
{ runtime, runtimeTemplate, type, chunkGraph, runtimeRequirements },
filename,
assetInfo,
contentHash,
fullContentHash
)
| 351 | * @returns {{ assetPath: string, assetInfo: AssetInfo }} asset path and info |
| 352 | */ |
| 353 | static getAssetPathWithInfo( |
| 354 | module, |
| 355 | generatorOptions, |
| 356 | { runtime, runtimeTemplate, type, chunkGraph, runtimeRequirements }, |
| 357 | filename, |
| 358 | assetInfo, |
| 359 | contentHash, |
| 360 | fullContentHash |
| 361 | ) { |
| 362 | const sourceFilename = AssetGenerator.getSourceFileName( |
| 363 | module, |
| 364 | runtimeTemplate |
| 365 | ); |
| 366 | |
| 367 | /** @type {undefined | string} */ |
| 368 | let assetPath; |
| 369 | |
| 370 | if (generatorOptions.publicPath !== undefined && type === JAVASCRIPT_TYPE) { |
| 371 | const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo( |
| 372 | generatorOptions.publicPath, |
| 373 | { |
| 374 | module, |
| 375 | runtime, |
| 376 | filename: sourceFilename, |
| 377 | chunkGraph, |
| 378 | contentHash, |
| 379 | contentHashFull: fullContentHash |
| 380 | } |
| 381 | ); |
| 382 | assetInfo = mergeAssetInfo(assetInfo, info); |
| 383 | assetPath = JSON.stringify(path + filename); |
| 384 | } else if ( |
| 385 | generatorOptions.publicPath !== undefined && |
| 386 | type === ASSET_URL_TYPE |
| 387 | ) { |
| 388 | const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo( |
| 389 | generatorOptions.publicPath, |
| 390 | { |
| 391 | module, |
| 392 | runtime, |
| 393 | filename: sourceFilename, |
| 394 | chunkGraph, |
| 395 | contentHash, |
| 396 | contentHashFull: fullContentHash |
| 397 | } |
| 398 | ); |
| 399 | assetInfo = mergeAssetInfo(assetInfo, info); |
| 400 | assetPath = path + filename; |
| 401 | } else if (type === JAVASCRIPT_TYPE) { |
| 402 | // add __webpack_require__.p |
| 403 | runtimeRequirements.add(RuntimeGlobals.publicPath); |
| 404 | assetPath = runtimeTemplate.concatenation( |
| 405 | { expr: RuntimeGlobals.publicPath }, |
| 406 | filename |
| 407 | ); |
| 408 | } else if (type === ASSET_URL_TYPE) { |
| 409 | const compilation = runtimeTemplate.compilation; |
| 410 | const path = |
no test coverage detected