Skip to content

Commit 673623b

Browse files
committed
Rename build script
1 parent 7ec44d1 commit 673623b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

build-all.mjs renamed to build.mjs

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env zx
22

3-
await $`npm run lint && npm run check && npx svelte-package`
4-
const out = await $`npx vite build -c vite.dist.config.js`
3+
await $`npm run lint && npx svelte-package`
4+
const packed = await $`npx vite build -c vite.dist.config.js`
55

66
// Prepare `/dist`
77
const pkg = await fs.readJson('package.json')
@@ -14,24 +14,30 @@ await $`cd dist && npx publint`
1414

1515
if (argv.packageOnly) process.exit()
1616

17-
await $`npm run build`
17+
await $`npx vite build`
1818

1919
// Calculate stats
20-
const sizes = out.stdout
20+
const sizes = packed
21+
.toString()
2122
.split('\n')
2223
.find((i) => i.includes('index.umd.js'))
2324
.split(' ')
2425
.filter((i) => !isNaN(parseFloat(i)))
2526
const cloc = JSON.parse(await $`npx cloc src/lib --json`).SUM.code.toString()
2627

2728
// Write stats into `/build`
28-
const shields = { schemaVersion: 1, color: 'blue' }
29-
await fs.writeJson('build/_min.json', { ...shields, label: 'minified', message: `${sizes[0]} kB` })
30-
await fs.writeJson('build/_gzip.json', { ...shields, label: 'gzipped', message: `${sizes[1]} kB` })
31-
await fs.writeJson('build/_loc.json', { ...shields, label: 'lines of code', message: cloc })
29+
const shields = (label, message, color) => ({
30+
schemaVersion: 1,
31+
label,
32+
message,
33+
color: color || 'blue'
34+
})
35+
await fs.writeJson('build/_min.json', shields('minified', `${sizes[0]} kB`))
36+
await fs.writeJson('build/_gzip.json', shields('gzipped', `${sizes[1]} kB`))
37+
await fs.writeJson('build/_loc.json', shields('lines of code', cloc, 'green'))
3238

3339
echo`
34-
Build complete!
40+
Build complete! [${chalk.green(cloc)}/${chalk.gray(sizes[0])}/${chalk.blue(sizes[1])}]
3541
3642
To deploy the demo, run:
3743
$ npx gh-pages -d build -t -f

0 commit comments

Comments
 (0)