Skip to content

Commit 49396aa

Browse files
committed
document this shit
1 parent df19b7c commit 49396aa

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

apps/svelte.dev/README.md

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,25 @@
1-
# create-svelte
1+
# svelte.dev
22

3-
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
3+
This is the app behind svelte.dev, the official Svelte site.
44

5-
## Creating a project
5+
## Development
66

7-
If you're seeing this, you've probably already done this step. Congrats!
7+
### Tutorial
88

9-
```bash
10-
# create a new project in the current directory
11-
npx sv create
9+
The tutorial consists of two technically different parts: The Svelte tutorial and the SvelteKit tutorial. The SvelteKit tutorial uses Stackblitz WebContainers under the hood in order to boot up a Node runtime in the browser. The Svelte tutorial uses Rollup in a web worker - it does not use WebContainers because a simple web worker is both faster and more reliable (there are known issues with iOS mobile).
1210

13-
# create a new project in my-app
14-
npx sv create my-app
15-
```
16-
17-
## Developing
18-
19-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20-
21-
```bash
22-
npm run dev
11+
WebContainers make use of certain features that are only available when certain security-related cors headers are set, namely these two:
2312

24-
# or start the server and open the app in a new browser tab
25-
npm run dev -- --open
13+
```
14+
Cross-Origin-Embedder-Policy: require-corp
15+
Cross-Origin-Opener-Policy: same-origin
2616
```
2717

28-
## Building
29-
30-
To create a production version of your app:
18+
Because we're doing soft navigation between pages, these headers need to be set for all responses, not just the ones from `/tutorial`.
3119

32-
```bash
33-
npm run build
34-
```
20+
The result of setting these headers is that the site can no longer embed URLs from other sites (like images from another domain) without those domains either having a `cross-origin-resource-policy: cross-origin` header (which most don't) or us adding the `crossorigin="anonymous"` attribute to the elements that load those URLs.
3521

36-
You can preview the production build with `npm run preview`.
22+
When writing content for the tutorial, you need to be aware of the differences of loading content:
3723

38-
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
24+
- When using content like images for the Svelte tutorial, either place them in the `static/tutorial` folder, or if it's from a different domain, add the `crossorigin` attribute
25+
- When using content like images for the SvelteKit tutorial, either place them into a `static` folder right in that chapter and reference them, or import them like you can do when using Vite (e.g. `import Svg from './some.svg';`)

0 commit comments

Comments
 (0)