diff --git a/registry/webpack/build.ts b/registry/webpack/build.ts index 8690f4794..518d40b45 100644 --- a/registry/webpack/build.ts +++ b/registry/webpack/build.ts @@ -1,17 +1,23 @@ +import path from 'path' import glob from 'glob' import { buildByEntry } from './config' +const shorten = (p: string) => path.dirname(p).replace('./registry/lib/', '') + export const builders = Object.fromEntries( ['component', 'plugin', 'doc'].map(type => { const src = `./registry/lib/${type}s/` return [ type, async ({ buildAll = false } = {}) => { - const entries = glob.sync(`${src}**/index.ts`) + const entries = glob.sync(`${src}**/index.ts`).map(entry => ({ + name: shorten(entry), + value: entry, + })) if (buildAll) { console.log(`[build all] discovered ${entries.length} ${type}s`) - return entries.map(entry => buildByEntry({ src, type, entry })) + return entries.map(({ value }) => buildByEntry({ src, type, entry: value })) } let entry: string @@ -25,9 +31,9 @@ export const builders = Object.fromEntries( }) entry = await prompt.run() } else { - ;[entry] = entries - console.log(`Build target · ${entry}`) + ;[{ value: entry }] = entries } + console.log(`Build target · ${entry}`) return [buildByEntry({ src, type, entry })] }, ]