UNPKG

umi-library

Version:

Library toolkit based on rollup and docz.

25 lines (22 loc) 765 B
import { cloneDeep, merge } from 'lodash'; import { IBundleOptions } from "./types"; function stripDotSlashPrefix(path) { return path.replace(/^\.\//, ''); } export default function (entry: string, opts: IBundleOptions): IBundleOptions { let clone = cloneDeep(opts); const stripedEntry = stripDotSlashPrefix(entry); if (clone.overridesByEntry) { Object.keys(clone.overridesByEntry).forEach((key) => { const stripedKey = stripDotSlashPrefix(key); if (stripedKey !== key) { clone.overridesByEntry[stripedKey] = clone.overridesByEntry[key]; } }); if (clone.overridesByEntry[stripedEntry]) { clone = merge(clone, clone.overridesByEntry[stripedEntry]); } delete clone.overridesByEntry; } return clone; }