File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,25 @@ export default defineConfig({
1919 if ( id . endsWith ( '.py' ) ) {
2020 return { code : `export default ${ JSON . stringify ( code ) } ;` , map : null } ;
2121 }
22+
23+ if ( id . endsWith ( '.txt' ) ) {
24+ if ( code . startsWith ( 'export default "data:text/plain;base64,' ) ) {
25+ const match = code . match ( / d a t a : t e x t \/ p l a i n ; b a s e 6 4 , ( .+ ?) " $ / ) ;
26+ if ( match ) {
27+ const base64Content = match [ 1 ] ;
28+ const decodedContent = Buffer . from (
29+ base64Content ,
30+ 'base64'
31+ ) . toString ( 'utf-8' ) ;
32+ return {
33+ code : `export default ${ JSON . stringify ( decodedContent ) } ;` ,
34+ map : null ,
35+ } ;
36+ }
37+ }
38+ return { code : `export default ${ JSON . stringify ( code ) } ;` , map : null } ;
39+ }
40+
2241 return null ;
2342 } ,
2443 } ,
@@ -53,6 +72,7 @@ export default defineConfig({
5372 esbuildOptions : {
5473 loader : {
5574 '.py' : 'text' ,
75+ '.txt' : 'text' ,
5676 } ,
5777 } ,
5878 } ,
You can’t perform that action at this time.
0 commit comments