Skip to content

Commit 4bf7205

Browse files
committed
Duplicate umd build
1 parent 797f8db commit 4bf7205

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

build-all.mjs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
#!/usr/bin/env zx
22

3+
const args = process.argv.slice(2)
4+
35
await $`npm run lint`
46
await $`npm run check`
5-
await $`npm run build`
67
await $`npx svelte-package`
78
const out = await $`npx vite build -c vite.dist.config.js`
9+
await fs.copy('dist/dist/index.umd.js', 'dist/dist/index.umd.cjs')
10+
11+
// Prepare `/dist`
12+
const pkg = await fs.readJson('package.json')
13+
pkg.scripts = undefined
14+
await fs.writeJson('dist/package.json', pkg, { spaces: 2 })
15+
await fs.copy('README.md', 'dist/README.md')
16+
await fs.copy('LICENSE', 'dist/LICENSE')
17+
await $`cd dist && npx publint`
18+
19+
if (args.includes('--packageOnly')) process.exit()
20+
21+
await $`npm run build`
822

923
// Calculate stats
1024
const sizes = out.stdout
1125
.split('\n')
12-
.find((i) => i.includes('index.umd.cjs'))
26+
.find((i) => i.includes('index.umd.js'))
1327
.split(' ')
1428
.filter((i) => !isNaN(parseFloat(i)))
1529
const cloc = JSON.parse(await $`npx cloc src/lib --json`).SUM.code.toString()
@@ -20,15 +34,9 @@ await fs.writeJson('build/_min.json', { ...shields, label: 'minified', message:
2034
await fs.writeJson('build/_gzip.json', { ...shields, label: 'gzipped', message: `${sizes[1]} kB` })
2135
await fs.writeJson('build/_loc.json', { ...shields, label: 'lines of code', message: cloc })
2236

23-
// Prepare `/dist`
24-
const pkg = await fs.readJson('package.json')
25-
pkg.scripts = undefined
26-
await fs.writeJson('dist/package.json', pkg, { spaces: 2 })
27-
await fs.copy('README.md', 'dist/README.md')
28-
await fs.copy('LICENSE', 'dist/LICENSE')
29-
await $`cd dist && npx publint`
30-
3137
echo`
38+
Build complete!
39+
3240
To deploy the demo, run:
3341
$ npx gh-pages -d build -t -f
3442

0 commit comments

Comments
 (0)