@@ -7,6 +7,37 @@ import tailwindcss from "@tailwindcss/vite"
77
88import { getGitSha } from "@roo-code/build"
99
10+ const wasmPlugin = ( ) : Plugin => ( {
11+ name : "wasm" ,
12+ async load ( id ) {
13+ if ( id . endsWith ( ".wasm" ) ) {
14+ const wasmBinary = await import ( id )
15+
16+ return `
17+ const wasmModule = new WebAssembly.Module(${ wasmBinary . default } );
18+ export default wasmModule;
19+ `
20+ }
21+ } ,
22+ } )
23+
24+ const persistPortPlugin = ( ) : Plugin => ( {
25+ name : "write-port-to-file" ,
26+ configureServer ( viteDevServer ) {
27+ viteDevServer ?. httpServer ?. once ( "listening" , ( ) => {
28+ const address = viteDevServer ?. httpServer ?. address ( )
29+ const port = address && typeof address === "object" ? address . port : null
30+
31+ if ( port ) {
32+ fs . writeFileSync ( resolve ( __dirname , ".." , ".vite-port" ) , port . toString ( ) )
33+ console . log ( `[Vite Plugin] Server started on port ${ port } ` )
34+ } else {
35+ console . warn ( "[Vite Plugin] Could not determine server port" )
36+ }
37+ } )
38+ } ,
39+ } )
40+
1041// https://vitejs.dev/config/
1142export default defineConfig ( ( { mode } ) => {
1243 let outDir = "../src/webview-ui/build"
@@ -79,34 +110,3 @@ export default defineConfig(({ mode }) => {
79110 assetsInclude : [ "**/*.wasm" , "**/*.wav" ] ,
80111 }
81112} )
82-
83- const wasmPlugin = ( ) : Plugin => ( {
84- name : "wasm" ,
85- async load ( id ) {
86- if ( id . endsWith ( ".wasm" ) ) {
87- const wasmBinary = await import ( id )
88-
89- return `
90- const wasmModule = new WebAssembly.Module(${ wasmBinary . default } );
91- export default wasmModule;
92- `
93- }
94- } ,
95- } )
96-
97- const persistPortPlugin = ( ) : Plugin => ( {
98- name : "write-port-to-file" ,
99- configureServer ( viteDevServer ) {
100- viteDevServer ?. httpServer ?. once ( "listening" , ( ) => {
101- const address = viteDevServer ?. httpServer ?. address ( )
102- const port = address && typeof address === "object" ? address . port : null
103-
104- if ( port ) {
105- fs . writeFileSync ( resolve ( __dirname , ".." , ".vite-port" ) , port . toString ( ) )
106- console . log ( `[Vite Plugin] Server started on port ${ port } ` )
107- } else {
108- console . warn ( "[Vite Plugin] Could not determine server port" )
109- }
110- } )
111- } ,
112- } )
0 commit comments