Skip to content

Commit

Permalink
feat: allow programmatic inputConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 3, 2021
1 parent 67b3e0a commit 9493837
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { rollupBuild } from './builder/rollup'
import { typesBuild } from './builder/untyped'
import { mkdistBuild } from './builder/mkdist'

export async function build (rootDir: string, stub: boolean) {
export async function build (rootDir: string, stub: boolean, inputConfig: BuildConfig = {}) {
// Determine rootDir
rootDir = resolve(process.cwd(), rootDir || '.')

Expand All @@ -26,13 +26,13 @@ export async function build (rootDir: string, stub: boolean) {
const pkg = _require('./package.json')

// Resolve preset
let preset = buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || {}
let preset = buildConfig.preset || pkg.unbuild?.preset || pkg.build?.preset || inputConfig.preset || {}
if (typeof preset === 'string') {
preset = _require(preset)
}

// Merge options
const options = defu(buildConfig, pkg.unbuild || pkg.build, preset, <BuildOptions>{
const options = defu(buildConfig, pkg.unbuild || pkg.build, inputConfig, preset, <BuildOptions>{
rootDir,
entries: [],
clean: true,
Expand Down

0 comments on commit 9493837

Please sign in to comment.