gf-vben-admin/build/vite/alias.ts
2021-03-31 23:52:11 +08:00

17 lines
378 B
TypeScript

import { resolve } from 'path';
import type { Alias } from 'vite';
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}
export function createAlias(alias: [string, string][]): Alias[] {
return alias.map((item) => {
const [alia, src] = item;
return {
find: new RegExp(alia),
replacement: pathResolve(src) + '/',
};
});
}