@@ -3,6 +3,7 @@ import { defineConfig, type Options } from "tsup";
33import react18Plugin from "esbuild-plugin-react18" ;
44import cssPlugin from "esbuild-plugin-react18-css" ;
55import { rdiPlugin } from "esbuild-plugin-rdi" ;
6+ import { webglPlugin } from "esbuild-plugin-webgl" ;
67
78export default defineConfig (
89 ( options : Options ) =>
@@ -19,30 +20,18 @@ export default defineConfig(
1920 name : "webgl" ,
2021 setup ( build ) {
2122 if ( ! options . watch )
22- build . onLoad ( { filter : / u t i l s \. t s $ / , namespace : "file" } , args => {
23+ build . onLoad ( { filter : / s i m u l a t o r \. t s $ / , namespace : "file" } , args => {
24+ console . log ( "utils ----- >" , args . path ) ;
2325 const text = fs . readFileSync ( args . path , "utf8" ) ;
2426 const contents = text
25- . replace ( / i f \( ! g l [ ^ } ] * } / gm, "" )
26- . replace ( / ; \s * i f \( ! [ ^ ; ] * ; / gm, "!;" )
27+ . replace ( / i f \( ! g l \. [ ^ } ] * } / gm, "" )
28+ . replace ( / ; \s * i f \( ! ( s h a d e r | p r o g r a m ) [ ^ ; ] * ; / gm, "!;" )
2729 . trim ( ) ;
2830 return { contents, loader : "ts" } ;
2931 } ) ;
30- // eslint-disable-next-line prefer-named-capture-group -- ok
31- build . onLoad ( { filter : / \. g l s l $ / , namespace : "file" } , args => {
32- const text = fs . readFileSync ( args . path , "utf8" ) ;
33- const lines = text
34- // remove comments
35- . replace ( / \/ \* .* \* \/ / gm, "" )
36- // remove white spaces around =
37- // .replace(/ = /g, "=")
38- . split ( "\n" )
39- . map ( line => line . trim ( ) )
40- . filter ( Boolean ) ;
41- const contents = `export default \`${ lines [ 0 ] } \n${ lines . slice ( 1 ) . join ( "" ) } \`` ;
42- return { contents, loader : "ts" } ;
43- } ) ;
4432 } ,
4533 } ,
34+ webglPlugin ( ) ,
4635 react18Plugin ( { disableJSXRequireDedup : true } ) ,
4736 cssPlugin ( { generateScopedName : "[folder]__[local]" } ) ,
4837 rdiPlugin ( ) ,
0 commit comments