File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,17 @@ const DESTINATION = "./main.js";
6
6
7
7
const url = new URL ( SOURCE , import . meta. url ) ;
8
8
9
- if ( Deno . args [ 0 ] === " build" ) {
10
- const result = await emit . bundle ( url , { minify : true } ) ;
9
+ async function build ( options : emit . BundleOptions ) : Promise < void > {
10
+ const result = await emit . bundle ( url , options ) ;
11
11
const { code } = result ;
12
12
await Deno . writeTextFile ( DESTINATION , code ) ;
13
+ }
14
+ if ( Deno . args [ 0 ] === "build" ) {
15
+ await build ( { minify : true } ) ;
13
16
} else if ( Deno . args [ 0 ] === "watch" ) {
14
17
const builder = debounce . debounce ( async ( ) => {
15
18
console . log ( "Starting to build..." ) ;
16
- const result = await emit . bundle ( url , {
17
- compilerOptions : { inlineSourceMap : true } ,
18
- } ) ;
19
- const { code } = result ;
20
- await Deno . writeTextFile ( DESTINATION , code ) ;
19
+ await build ( { compilerOptions : { inlineSourceMap : true } } ) ;
21
20
console . log ( "Building done!" ) ;
22
21
} , 500 ) ;
23
22
const watcher = Deno . watchFs ( "./src/" ) ;
You can’t perform that action at this time.
0 commit comments