Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
emi420 committed Dec 18, 2024
2 parents e392dd0 + 332d893 commit 6ba6d52
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ site

# Common system files
.DS_Store

# Build scripts
!scripts/build.js
37 changes: 37 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { deleteAsync } from 'del';
import { exec } from 'child_process';
import { globby } from 'globby';
import esbuild from 'esbuild';
import fs from 'fs/promises';
import util from 'util';
const outdir = 'dist';
const execPromise = util.promisify(exec);
const bundleDirectories = [outdir];

const config = {
format: 'esm',
target: 'es2017',
entryPoints: [
'./src/hotosm-ui.ts',
...(await globby('./src/components/**/!(*.(style)).ts')),
...(await globby('./src/react/**/*.ts'))
],
chunkNames: 'chunks/[name].[hash]',
bundle: true,
splitting: true,
external: undefined,
minify: true,
tsconfig: 'tsconfig.json',
loader: {
'.svg': 'dataurl',
'.ts': 'ts',
},
packages: 'external',
outdir
};

await Promise.all([...bundleDirectories.map(dir => deleteAsync(dir))]);
await fs.mkdir(outdir, { recursive: true });
execPromise(`tsc --project ./tsconfig.prod.json --outdir "${outdir}"`, { stdio: 'inherit' });
esbuild.build(config).catch(() => process.exit(1));

0 comments on commit 6ba6d52

Please sign in to comment.