build.mjs 718 B

1234567891011121314151617181920212223242526272829
  1. import fs from 'node:fs';
  2. import path from 'node:path';
  3. import esbuild from 'esbuild';
  4. import { rimraf } from 'rimraf';
  5. /**
  6. * @param i18nPath {string}
  7. */
  8. export async function build(i18nPath) {
  9. fs.cpSync(i18nPath, path.resolve('lib', 'i18n.ts'));
  10. await esbuild.build({
  11. entryPoints: ['./index.ts'],
  12. tsconfig: './tsconfig.json',
  13. bundle: true,
  14. packages: 'bundle',
  15. target: 'es6',
  16. outdir: './dist',
  17. sourcemap: true,
  18. format: 'esm',
  19. });
  20. const outDir = path.resolve('..', '..', 'dist');
  21. const localePath = path.resolve(outDir, '_locales');
  22. rimraf.sync(localePath);
  23. fs.cpSync(path.resolve('locales'), localePath, { recursive: true });
  24. console.log('I18n build complete');
  25. }