tachybase_todo/packages/plugins/@nocobase/plugin-china-region/build.config.ts
sealday 3e58c54aa8 feat: 仓库二期 (#719)
Co-authored-by: hello@lv <2256334253@qq.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-authored-by: sealday <sealday@gmail.com>
Reviewed-on: daoyoucloud/tachybase#719
2024-05-08 16:20:31 +08:00

24 lines
636 B
TypeScript

import { defineConfig } from '@tachybase/build';
import fs from 'fs/promises';
import path from 'path';
import { existsSync } from 'fs';
export default defineConfig({
afterBuild: async (log) => {
const dir = path.resolve(__dirname, './dist/china-division');
if (existsSync(dir)) {
await fs.rm(dir, { recursive: true });
}
const keys = ['areas', 'cities', 'provinces'];
for (const key of keys) {
log(`coping ${key}.json`);
await fs.cp(require.resolve(`china-division/dist/${key}.json`), path.resolve(dir, `${key}.json`), {
recursive: true,
force: true,
});
}
},
});