Skip to content

Commit

Permalink
Merge pull request #8 from paul-vd/patch-1
Browse files Browse the repository at this point in the history
fix: fixes alias resolver to allow arrays
  • Loading branch information
theKashey authored Nov 8, 2021
2 parents b56fca3 + 83bf10c commit f88fb38
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ const getChunks = ({ namedChunkGroups }: WebStats): Chunks =>

return acc;
}, {} as Chunks);

const resolveAliases = (cwd: string, aliases: Record<string, string>): Record<string, string> =>
Object.keys(aliases).reduce((acc, key) => ({ ...acc, [key]: relative(cwd, aliases[key]) }), {});

const resolveAliases = (cwd: string, aliases: Record<string, string | string[]>): Record<string, string | string[]> => {
return Object.keys(aliases).reduce((acc, key) => {
const alias = aliases[key];
const paths = Array.isArray(alias) ? alias.map(aliasPath => relative(cwd, aliasPath)) : relative(cwd, alias);
return { ...acc, [key]: paths }
}, {})
};

export const importStats = (stats: WebStats, extraProps: Record<string, any> = {}): ImportedStat => {
const cwd = process.cwd();
Expand Down

0 comments on commit f88fb38

Please sign in to comment.