Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to run SvelteKit & Cloudflare Page locally?

$
0
0

I'm trying to create a new app using SvelteKit & Cloudflare Pages and I'm struggling with running the application locally in a proper manner. Currently, in order to get the app running locally I run 2 scripts in 2 different terminals:

  1. vite build --watch
    • this creates the cloudflare directories in the .svelte-kit directory
    • vite dev doesn't seem to create the cloudflare directories so I've used vite build
  2. wrangler pages dev .svelte-kit/cloudflare --live-reload
    • this starts the app

The above approach works, namely, it starts the app as expected. The problem is that any changes I'm making to the code are visible in the browser tab after 3-4 seconds which from a DX point of view is far from enjoying. Ideally, when running locally, any code changes should be visible in the browser tab in 1-sec-ish.

This is the first time I'm tinkering with SvelteKit & Cloudflare Pages so I'm sure I'm missing something. Therefore, the question is: how should one run a SvelteKit & Cloudflare Pages app locally "the right way"? "The right way" means that I can see the effect of my code changes in 1-sec-ish and I can run the app locally using something like wrangler or miniflare in order for the local environment to resemble as much as possible the production one.

P.s.: I've checked docs like https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/ and https://www.npmjs.com/package/@sveltejs/adapter-cloudflarereadme.md but they focus mainly on how to run the app in production
P.p.s: I believe the 2 scripts can be merged into a single one using something like concurrently but at the moment my focus is on having quick feedback when it comes to code changes
P.p.p.s.: bundling and tinkering with the javascript modules themselves is not one of my strong points yet so if you have any helpful articles, they're more than welcome


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>