11/// <reference lib="deno.ns" />
22import * as esbuild from '@esbuild' ;
3- import { denoPlugin as esbuildPluginDeno } from "@deno/esbuild-plugin" ;
43import { bold , green , magenta } from '@std/fmt/colors' ;
54import { parseArgs } from '@std/cli/parse-args' ;
65import { copy as esbuildPluginCopy } from './plugins/copy.ts' ;
6+ import { denoPlugin as esbuildPluginDeno } from "@deno/esbuild-plugin" ;
7+ import { htmlScriptTags as esbuildPluginHtmlScriptTags } from './plugins/html_script_tags.ts' ;
78
89const args = parseArgs < {
910 watch : boolean | undefined ,
@@ -18,7 +19,6 @@ const copyConfig : esbuild.BuildOptions = {
1819 outdir : './dist' ,
1920 outbase : './src/client' ,
2021 entryPoints : [
21- './src/client/**/index.html' ,
2222 './src/client/**/assets/*' ,
2323 './src/client/static/**/*'
2424 ] ,
@@ -27,7 +27,7 @@ const copyConfig : esbuild.BuildOptions = {
2727 ]
2828}
2929
30- const filesConfig : esbuild . BuildOptions = {
30+ const buildConfig : esbuild . BuildOptions = {
3131 allowOverwrite : true ,
3232 logLevel : args . logLevel ?? 'info' ,
3333 legalComments : args . develop ? 'inline' : 'none' ,
@@ -44,6 +44,7 @@ const filesConfig : esbuild.BuildOptions = {
4444 outdir : './dist' ,
4545 outbase : './src/client' ,
4646 entryPoints : [
47+ './src/client/**/index.html' ,
4748 './src/client/index.tsx' ,
4849 './src/client/index.css'
4950 ] ,
@@ -52,6 +53,7 @@ const filesConfig : esbuild.BuildOptions = {
5253 'nesting' : true
5354 } ,
5455 plugins : [
56+ esbuildPluginHtmlScriptTags ( ) ,
5557 esbuildPluginDeno ( {
5658 preserveJsx : true ,
5759 debug : args . develop ?? false
@@ -65,11 +67,11 @@ const timestampNow = Date.now();
6567
6668if ( args . watch ) {
6769 esbuild . context ( copyConfig ) . then ( ( context ) => context . watch ( ) ) ;
68- esbuild . context ( filesConfig ) . then ( ( context ) => context . watch ( ) ) ;
70+ esbuild . context ( buildConfig ) . then ( ( context ) => context . watch ( ) ) ;
6971} else {
7072 Promise . all ( [
7173 esbuild . build ( copyConfig ) ,
72- esbuild . build ( filesConfig )
74+ esbuild . build ( buildConfig )
7375 ] ) . then ( ( ) => {
7476 esbuild . stop ( ) ;
7577 console . log ( green ( `esbuild ${ esbuild . version } finished build in ${ ( Date . now ( ) - timestampNow ) . toString ( ) } ms.` ) ) ;
0 commit comments