Skip to content

Commit 6685cae

Browse files
committed
new esbuild and removal of prebuild running twice
1 parent 63923c3 commit 6685cae

File tree

4 files changed

+2169
-812
lines changed

4 files changed

+2169
-812
lines changed

build-components.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// build-components.js
2+
const esbuild = require('esbuild');
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
const componentsPath = path.resolve(__dirname, 'src/components/ui');
7+
const outDir = path.resolve(__dirname, 'dist/temp-cleanup');
8+
9+
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
10+
11+
const components = fs.readdirSync(componentsPath)
12+
.filter((file) => fs.statSync(path.join(componentsPath, file)).isDirectory());
13+
14+
Promise.all(components.map(component => {
15+
const entry = path.join(componentsPath, component, `${component}.tsx`);
16+
const outfile = path.join(outDir, `${component}.js`);
17+
return esbuild.build({
18+
entryPoints: [entry],
19+
outfile,
20+
bundle: true,
21+
format: 'esm',
22+
minify: true,
23+
external: ['react', 'react-dom', 'react/jsx-runtime'],
24+
banner: { js: `'use client';` },
25+
sourcemap: false,
26+
// Add more esbuild options as needed
27+
});
28+
})).then(() => {
29+
console.log('All components built with esbuild!');
30+
}).catch((err) => {
31+
console.error(err);
32+
process.exit(1);
33+
});

0 commit comments

Comments
 (0)