Skip to content

Commit

Permalink
Wire up some more
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Oct 2, 2024
1 parent e6ed313 commit 8f2b1c8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
18 changes: 18 additions & 0 deletions apps/tracer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"use-debounce": "^10.0.3"
},
"devDependencies": {
"@types/node": "^22.7.4",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
25 changes: 23 additions & 2 deletions apps/tracer/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import { defineConfig } from "vite";
import fs from "fs";
import path from "path";
import { defineConfig, Plugin } from "vite";
import react from "@vitejs/plugin-react";

const R2_WASM_PATH = path.join(import.meta.dirname, "node_modules", "@frida", "react-use-r2", "dist", "r2.wasm");

const r2WasmPlugin: Plugin = {
name: "r2-wasm-plugin",
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.originalUrl?.endsWith("/r2.wasm")) {
const data = fs.readFileSync(R2_WASM_PATH);
res.setHeader("Content-Length", data.length);
res.setHeader("Content-Type", "application/wasm");
res.end(data, "binary");
return;
}
next();
});
},
};

export default defineConfig({
plugins: [react()],
plugins: [react(), r2WasmPlugin],
assetsInclude: "**/*.wasm",
build: {
rollupOptions: {
output: {
Expand Down

0 comments on commit 8f2b1c8

Please sign in to comment.