1
1
#!/usr/bin/env zx
2
2
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`
5
5
6
6
// Prepare `/dist`
7
7
const pkg = await fs . readJson ( 'package.json' )
@@ -14,24 +14,30 @@ await $`cd dist && npx publint`
14
14
15
15
if ( argv . packageOnly ) process . exit ( )
16
16
17
- await $ `npm run build`
17
+ await $ `npx vite build`
18
18
19
19
// Calculate stats
20
- const sizes = out . stdout
20
+ const sizes = packed
21
+ . toString ( )
21
22
. split ( '\n' )
22
23
. find ( ( i ) => i . includes ( 'index.umd.js' ) )
23
24
. split ( ' ' )
24
25
. filter ( ( i ) => ! isNaN ( parseFloat ( i ) ) )
25
26
const cloc = JSON . parse ( await $ `npx cloc src/lib --json` ) . SUM . code . toString ( )
26
27
27
28
// 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' ) )
32
38
33
39
echo `
34
- Build complete!
40
+ Build complete! [ ${ chalk . green ( cloc ) } / ${ chalk . gray ( sizes [ 0 ] ) } / ${ chalk . blue ( sizes [ 1 ] ) } ]
35
41
36
42
To deploy the demo, run:
37
43
$ npx gh-pages -d build -t -f
0 commit comments