import { IApi } from 'umi'; import fs from 'fs-extra'; import path from 'path'; export default async (api: IApi) => { api.describe({ key: 'pdfViewer', config: { schema(joi) { return joi.object(); }, }, }); const { paths, userConfig } = api; // @ts-ignore const publicPath = path.join(paths.cwd, 'public/viewer') const { pdfViewer } = userConfig; if (pdfViewer) { await fs.removeSync(publicPath); await fs.copySync(path.join(__dirname, '../pdfjs'), publicPath); } }