MCPcopy
hub / github.com/vitejs/vite / getLegacyOutputFileName

Function getLegacyOutputFileName

packages/plugin-legacy/src/index.ts:416–448  ·  view source on GitHub ↗
(
        fileNames:
          | string
          | ((chunkInfo: Rollup.PreRenderedChunk) => string)
          | undefined,
        defaultFileName = '[name]-legacy-[hash].js',
      )

Source from the content-addressed store, hash-verified

414 }
415
416 const getLegacyOutputFileName = (
417 fileNames:
418 | string
419 | ((chunkInfo: Rollup.PreRenderedChunk) => string)
420 | undefined,
421 defaultFileName = '[name]-legacy-[hash].js',
422 ): string | ((chunkInfo: Rollup.PreRenderedChunk) => string) => {
423 if (!fileNames) {
424 return path.posix.join(config.build.assetsDir, defaultFileName)
425 }
426
427 return (chunkInfo) => {
428 let fileName =
429 typeof fileNames === 'function' ? fileNames(chunkInfo) : fileNames
430
431 if (fileName.includes('[name]')) {
432 // [name]-[hash].[format] -> [name]-legacy-[hash].[format]
433 fileName = fileName.replace('[name]', '[name]-legacy')
434 } else if (nonLeadingHashInFileNameRE.test(fileName)) {
435 // custom[hash].[format] -> [name]-legacy[hash].[format]
436 // custom-[hash].[format] -> [name]-legacy-[hash].[format]
437 // custom.[hash].[format] -> [name]-legacy.[hash].[format]
438 // custom.[hash:10].[format] -> custom-legacy.[hash:10].[format]
439 fileName = fileName.replace(prefixedHashInFileNameRE, '-legacy$&')
440 } else {
441 // entry.js -> entry-legacy.js
442 // entry.min.js -> entry-legacy.min.js
443 fileName = fileName.replace(/(.+?)\.(.+)/, '$1-legacy.$2')
444 }
445
446 return fileName
447 }
448 }
449
450 const createLegacyOutput = (
451 options: Rollup.OutputOptions = {},

Callers 1

createLegacyOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected