11#!/usr/bin/env node
22
3- import * as esbuild from 'esbuild'
4- import {
5- lessLoader
6- }
7- from 'esbuild-plugin-less' ;
3+ import * as esbuild from 'esbuild' ;
4+ import { lessLoader } from 'esbuild-plugin-less' ;
85import {
96 writeFile ,
107 opendir ,
11- unlink
12- }
13- from 'node:fs/promises' ;
8+ unlink ,
9+ } from 'node:fs/promises' ;
10+ import console from 'node:console' ;
11+ import process from 'node:process' ;
1412import path from 'node:path' ;
1513import parseArgs from 'minimist' ;
1614
@@ -21,16 +19,16 @@ const config = {
2119 ] ,
2220 assetNames : '[name]-[hash]' ,
2321 entryNames : '[name]-[hash]' ,
24- format : 'esm' ,
25- outdir : 'root/assets' ,
26- bundle : true ,
27- sourcemap : true ,
28- inject : [ 'root/static/js/inject.mjs' ] ,
29- loader : {
30- '.eot' : 'file' ,
31- '.svg' : 'file' ,
32- '.ttf' : 'file' ,
33- '.woff' : 'file' ,
22+ format : 'esm' ,
23+ outdir : 'root/assets' ,
24+ bundle : true ,
25+ sourcemap : true ,
26+ inject : [ 'root/static/js/inject.mjs' ] ,
27+ loader : {
28+ '.eot' : 'file' ,
29+ '.svg' : 'file' ,
30+ '.ttf' : 'file' ,
31+ '.woff' : 'file' ,
3432 '.woff2' : 'file' ,
3533 } ,
3634 plugins : [
@@ -40,18 +38,18 @@ const config = {
4038
4139 setup ( build ) {
4240 build . onResolve ( {
43- filter : / ^ \/ /
44- } ,
45- ( ) => ( {
46- external : true
47- } ) ,
41+ filter : / ^ \/ / ,
42+ } ,
43+ ( ) => ( {
44+ external : true ,
45+ } ) ,
4846 ) ;
4947
5048 build . initialOptions . metafile = true ;
5149 build . onStart ( ( ) => {
52- console . log ( 'building assets...' )
50+ console . log ( 'building assets...' ) ;
5351 } ) ;
54- build . onEnd ( async result => {
52+ build . onEnd ( async ( result ) => {
5553 const outputs = result ?. metafile ?. outputs ;
5654 if ( outputs ) {
5755 const files = Object . keys ( outputs ) . sort ( )
@@ -70,7 +68,7 @@ const config = {
7068 }
7169 } ) ;
7270 }
73- } ,
71+ } ( ) ,
7472 ] ,
7573} ;
7674
@@ -86,7 +84,7 @@ if (args.minify) {
8684}
8785if ( args . clean ) {
8886 for await ( const file of await opendir ( config . outdir , {
89- withFileTypes : true
87+ withFileTypes : true ,
9088 } ) ) {
9189 const filePath = path . join ( file . parentPath , file . name ) ;
9290 if ( file . name . match ( / ^ \. / ) ) {
@@ -105,7 +103,7 @@ if (args.clean) {
105103const ctx = await esbuild . context ( config ) ;
106104if ( args . watch ) {
107105 await ctx . watch ( ) ;
108- const sig = await new Promise ( resolve => {
106+ const sig = await new Promise ( ( resolve ) => {
109107 [
110108 'SIGTERM' ,
111109 'SIGQUIT' ,
0 commit comments