Skip to content

Commit 6f06bed

Browse files
committed
[fix] get it working for local system on latest version
1 parent 0997e3a commit 6f06bed

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ This repo uses [pnpm](https://pnpm.io/).
88

99
## Running the app
1010

11-
At the moment, the only way this works is if you clone the repo, add an `.env` file with `VITE_USE_FILESYSTEM=true` in it and run the app locally with `pnpm dev` or `pnpm build && pnpm preview`.
11+
First, run `node scripts/create-common-bundle`. This packages up everything that's needed to run a SvelteKit app (Vite, Esbuild, SvelteKit, Svelte compiler etc) which can subsequently be unpacked on a server to create and run and instance of a SvelteKit application (which powers the output window of the tutorial).
1212

13-
In future, it will run both locally and on the web (using [WebContainers](https://blog.stackblitz.com/posts/introducing-webcontainers/)).
13+
The next steps depend on whether you want to run this locally in filesystem mode, or in WebContainer mode. For now, it works with filesystem mode only locally. In future, it will run both locally and on the web (using [WebContainers](https://blog.stackblitz.com/posts/introducing-webcontainers/)).
14+
15+
### Local/filesystem mode
16+
17+
1. add an `.env` file with `VITE_USE_FILESYSTEM=true` in it
18+
2. Run the app locally with `pnpm dev` or `pnpm build && pnpm preview`.
19+
20+
### WebContainer mode
21+
22+
1. if an `.env` file exists, modify it so there's `VITE_USE_FILESYSTEM=` in it
23+
2. Run the app locally with `pnpm dev` or `pnpm build && pnpm preview`.

content/tutorial/common/vite.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ import { sveltekit } from '@sveltejs/kit/vite';
22

33
/** @type {import('vite').UserConfig} */
44
export default {
5-
plugins: [sveltekit()]
5+
plugins: [sveltekit()],
6+
server: {
7+
fs: {
8+
strict: false
9+
}
10+
}
611
};

src/routes/backend/apps.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export async function create({ files }) {
5353

5454
// TODO this enables embedding on cross-origin sites, which is
5555
// necessary for the JSNation talk, but will currently break if an app
56-
// already has a src/hooks.js file (though it could be worked
56+
// already has a src/hooks.server.js file (though it could be worked
5757
// around easily enough if necessary)
58-
if (!files.find((stub) => stub.name === '/src/hooks.js')) {
59-
fs.writeFileSync(`.apps/${id}/src/hooks.js`, hooks_src);
58+
if (!files.find((stub) => stub.name === '/src/hooks.server.js')) {
59+
fs.writeFileSync(`.apps/${id}/src/hooks.server.js`, hooks_src);
6060
}
6161

6262
const port = await ports.find(3001);

0 commit comments

Comments
 (0)