denoVite
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
A Vite project running on Val Town. The server.tsx
serves the project. If you make any edits the server will rebuild on the next request. All code is built using Deno on a separate build+proxy server. You can view the source here: https://github.com/maxmcd/vite-proxy
The vite build server is a proxy. Any HTTP Val request is proxied to the build server:
const projectVal = parseProject(import.meta.url);
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const path = `/${projectVal.username}/${projectVal.name}@${projectVal.version}${url.pathname}`;
const proxyUrl = new URL(path, "https://vite-proxy.ng-demo.valtown.net").toString();
const response = await fetch(proxyUrl);
When a request is recieved, the proxy downloads the entire project source (it can't be private) and builds it using Deno. Once the build is complete, all resulting files are cached and served quickly for future requests.