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

Function buildOutputOptions

packages/vite/src/node/build.ts:689–792  ·  view source on GitHub ↗
(output: OutputOptions = {})

Source from the content-addressed store, hash-verified

687 }
688
689 const buildOutputOptions = (output: OutputOptions = {}): OutputOptions => {
690 // @ts-expect-error See https://github.com/vitejs/vite/issues/5812#issuecomment-984345618
691 if (output.output) {
692 logger.warn(
693 `You've set "rolldownOptions.output.output" in your config. ` +
694 `This is deprecated and will override all Vite.js default output options. ` +
695 `Please use "rolldownOptions.output" instead.`,
696 )
697 }
698 if (output.file) {
699 throw new Error(
700 `Vite does not support "rolldownOptions.output.file". ` +
701 `Please use "rolldownOptions.output.dir" and "rolldownOptions.output.entryFileNames" instead.`,
702 )
703 }
704 if (output.sourcemap) {
705 logger.warnOnce(
706 colors.yellow(
707 `Vite does not support "rolldownOptions.output.sourcemap". ` +
708 `Please use "build.sourcemap" instead.`,
709 ),
710 )
711 }
712
713 const format = output.format || 'es'
714 const jsExt =
715 (ssr && !isSsrTargetWebworkerEnvironment) || libOptions
716 ? resolveOutputJsExtension(
717 format,
718 findNearestPackageData(root, packageCache)?.data.type,
719 )
720 : 'js'
721 return {
722 dir: outDir,
723 // Default format is 'es' for regular and for SSR builds
724 format,
725 exports: 'auto',
726 sourcemap: options.sourcemap,
727 name: libOptions ? libOptions.name : undefined,
728 // hoistTransitiveImports: libOptions ? false : undefined,
729 // es2015 enables `generatedCode.symbols`
730 // - #764 add `Symbol.toStringTag` when build es module into cjs chunk
731 // - #1048 add `Symbol.toStringTag` for module default export
732 generatedCode: {
733 preset: 'es2015',
734 },
735 entryFileNames: ssr
736 ? `[name].${jsExt}`
737 : libOptions
738 ? ({ name }) =>
739 resolveLibFilename(
740 libOptions,
741 format,
742 name,
743 root,
744 jsExt,
745 packageCache,
746 )

Callers 1

resolveRolldownOptionsFunction · 0.85

Calls 5

findNearestPackageDataFunction · 0.90
resolveOutputJsExtensionFunction · 0.85
resolveLibFilenameFunction · 0.85
warnMethod · 0.65
warnOnceMethod · 0.65

Tested by

no test coverage detected