-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
36 lines (30 loc) · 901 Bytes
/
build.js
File metadata and controls
36 lines (30 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { build } from 'esbuild';
import { sassPlugin } from 'esbuild-sass-plugin'
import { readdir, stat } from 'fs/promises';
import path from 'path';
const packagesDir = './packages';
const entries = await readdir(packagesDir);
for (const entry of entries) {
const packagePath = path.join(packagesDir, entry);
const stats = await stat(packagePath);
if (stats.isDirectory()) {
const entryFile = path.join(packagePath, 'index.js');
try {
await build({
entryPoints: [entryFile],
bundle: true,
minify: false,
outdir: path.join(packagePath, 'dist'),
platform: 'browser',
loader: {
'.svg': 'text',
'.html': 'text'
},
plugins: [sassPlugin({ type: 'css-text' })],
});
console.log(`Built ${entry}`);
} catch (err) {
console.error(`Failed to build ${entry}:`, err);
}
}
}