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

Function resolveLibCssFilename

packages/vite/src/node/plugins/css.ts:3585–3605  ·  view source on GitHub ↗
(
  libOptions: LibraryOptions,
  root: string,
  packageCache?: PackageCache,
)

Source from the content-addressed store, hash-verified

3583}
3584
3585export function resolveLibCssFilename(
3586 libOptions: LibraryOptions,
3587 root: string,
3588 packageCache?: PackageCache,
3589): string {
3590 if (typeof libOptions.cssFileName === 'string') {
3591 return `${libOptions.cssFileName}.css`
3592 } else if (typeof libOptions.fileName === 'string') {
3593 return `${libOptions.fileName}.css`
3594 }
3595
3596 const packageJson = findNearestMainPackageData(root, packageCache)?.data
3597 const name = packageJson ? getPkgName(packageJson.name) : undefined
3598
3599 if (!name)
3600 throw new Error(
3601 'Name in package.json is required if option "build.lib.cssFileName" is not provided.',
3602 )
3603
3604 return `${name}.css`
3605}

Callers 2

css.spec.tsFile · 0.90
getCssBundleNameFunction · 0.85

Calls 2

getPkgNameFunction · 0.90

Tested by

no test coverage detected