@hyperfrontend/builder/package/assets

assets

Generic asset-copy primitive consumed by the package phase.

copyAssets(specs, outputPath, srcPkg) materializes a list of AssetSpec entries into the build output. Each spec selects its inputs via either an explicit files: string[] list or a POSIX-style glob: string evaluated relative to spec.from, and writes them under <outputPath>/<spec.to> (defaulting to the dist root). Specs gated by a condition predicate are skipped when the predicate returns false. Builder ships with zero default-asset knowledge — wrappers supply their own asset spec lists.

API Reference

ƒ Functions

§function

copyAssets(specs: AssetSpec[], outputPath: string, srcPkg: PackageJson): void

Copies one or more asset specs into the build output directory.
Each spec selects its inputs in one of two ways:
  • spec.files: explicit list of relative paths under spec.from. Missing entries
are silently skipped.
  • spec.glob: POSIX-style glob evaluated relative to spec.from.
The destination is <outputPath>/<spec.to>, defaulting to the dist root when spec.to is omitted or equal to '.'. Specs whose condition predicate returns false are skipped entirely.

Parameters

NameTypeDescription
§specs
AssetSpec[]
Asset specifications to materialize.
§outputPath
string
Absolute path to the build output directory.
§srcPkg
PackageJson
Source package.json, supplied to each spec's condition predicate.

Example

Copying README + LICENSE into the dist root

copyAssets(
  [
    { from: '/abs/libs/foo', files: ['README.md', 'CHANGELOG.md'] },
    { from: '/abs/repo', files: ['LICENSE.md', 'SECURITY.md'] },
  ],
  '/abs/dist/libs/foo',
  srcPkg
)