2022-03-03 01:04:56 -05:00
|
|
|
const esbuild = require('esbuild');
|
2022-03-13 21:30:37 -05:00
|
|
|
const { existsSync } = require('fs');
|
2022-03-13 21:13:18 -05:00
|
|
|
const { rm } = require('fs/promises');
|
2022-10-23 14:16:59 -05:00
|
|
|
const { recursiveReadDir } = require('next/dist/lib/recursive-readdir');
|
2022-03-03 01:04:56 -05:00
|
|
|
|
|
|
|
(async () => {
|
2022-03-13 21:30:37 -05:00
|
|
|
if (existsSync('./dist')) {
|
|
|
|
await rm('./dist', { recursive: true });
|
|
|
|
}
|
2022-03-13 21:13:18 -05:00
|
|
|
|
2022-10-23 14:16:59 -05:00
|
|
|
const entryPoints = await recursiveReadDir('./src', /.*\.(ts)$/, /(themes|queries|pages)/);
|
|
|
|
|
2022-03-03 01:04:56 -05:00
|
|
|
await esbuild.build({
|
|
|
|
tsconfig: 'tsconfig.json',
|
|
|
|
outdir: 'dist',
|
|
|
|
platform: 'node',
|
2022-10-23 14:16:59 -05:00
|
|
|
entryPoints,
|
2022-03-03 01:04:56 -05:00
|
|
|
format: 'cjs',
|
|
|
|
resolveExtensions: ['.ts', '.js'],
|
|
|
|
write: true,
|
2022-07-28 13:03:22 -05:00
|
|
|
sourcemap: true,
|
2022-03-03 01:04:56 -05:00
|
|
|
});
|
2022-10-19 21:43:01 -05:00
|
|
|
})();
|