Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] project structure #5430

Merged
merged 83 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
aa7a4a0
Project Structure
Mlocik97 May 5, 2022
a9b6062
formating
Mlocik97 May 5, 2022
cf9e836
spaces
Mlocik97 May 5, 2022
00dde94
Update 01-project-structure.md
Mlocik97 May 5, 2022
49f3077
Update 01-project-structure.md
Mlocik97 May 5, 2022
e4b6164
Update 01-project-structure.md
Mlocik97 May 5, 2022
d7990e7
Update 01-project-structure.md
Mlocik97 May 5, 2022
25a0110
Update 01-project-structure.md
Mlocik97 May 5, 2022
076f7ea
Update 01-project-structure.md
Mlocik97 May 5, 2022
4410cfd
Update 01-project-structure.md
Mlocik97 May 5, 2022
59abe08
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
66ed00f
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
f8f1b8a
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
157fd70
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
e4a0a39
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
e427ca7
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
83bda89
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
94fffe0
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
cef6fe9
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
b970fc5
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
5495d42
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
4a82124
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
2980cff
Update 01-project-structure.md
Mlocik97 May 5, 2022
ec8d85a
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
7cdab00
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
1867c23
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
4c52fcf
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
b009781
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
44e06d5
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
8c3241b
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
f341d2f
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
abd6cb4
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
fade1a8
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
11bdce2
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
2d16173
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
1a528d9
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
117e8e4
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
e949c87
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
f74577a
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
e207ef3
Update 01-project-structure.md
Mlocik97 May 5, 2022
a823857
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
73c2efb
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
7a81291
Update 01-project-structure.md
Mlocik97 May 5, 2022
df426b4
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
92e662c
Update 01-project-structure.md
Mlocik97 May 5, 2022
26e3ebc
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
8763164
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
c84ce33
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
a8f4797
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
112fa3e
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
1028b62
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
75a3a80
Update documentation/docs/01-project-structure.md
Mlocik97 May 5, 2022
74d4730
[chore] upgrade eslint-plugin-svelte3
benmccann May 5, 2022
58f56b7
Merge branch 'eslint-plugin-svelte3'
Mlocik97 May 5, 2022
32e4f49
Update documentation/docs/01-project-structure.md
Mlocik97 May 6, 2022
c748641
Merge branch 'master' into master
Mlocik97 May 11, 2022
75a10c5
Merge branch 'master' into master
Mlocik97 May 12, 2022
fae169d
Merge branch 'master' into master
Mlocik97 May 13, 2022
7ada1ee
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 14, 2022
0e5dd49
Merge branch 'master' into master
Mlocik97 May 14, 2022
3954f72
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 17, 2022
8c19d8b
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 18, 2022
2771e2d
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 18, 2022
49094d7
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 19, 2022
74bf221
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 19, 2022
fb84136
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 20, 2022
b17aecf
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 20, 2022
918c9a3
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 23, 2022
885d0f8
Merge remote-tracking branch 'upstream/master'
Mlocik97 May 24, 2022
fb86350
Update 01-project-structure.md
Mlocik97 Jun 5, 2022
ba7a70a
Merge remote-tracking branch 'upstream/master'
Mlocik97 Jun 22, 2022
251bc59
Update 01-project-structure.md
Mlocik97 Jun 24, 2022
25e18d8
Update documentation/docs/01-project-structure.md
Mlocik97 Jun 24, 2022
2dd0396
Merge remote-tracking branch 'upstream/master'
Mlocik97 Jun 29, 2022
cbbebe0
Merge remote-tracking branch 'upstream/master'
Mlocik97 Jul 1, 2022
64a029b
Update 01-project-structure.md
Mlocik97 Jul 7, 2022
ceed586
Update 01-project-structure.md
Mlocik97 Jul 7, 2022
fe32426
Update 01-project-structure.md
Mlocik97 Jul 7, 2022
cf80af1
Merge remote-tracking branch 'upstream/master'
Mlocik97 Jul 7, 2022
9576ed2
Update documentation/docs/01-project-structure.md
Mlocik97 Jul 7, 2022
235d158
Merge remote-tracking branch 'upstream/master'
Mlocik97 Jul 8, 2022
29bf54a
Merge branch 'master' of github.com:Mlocik97/kit into Mlocik97-master
Rich-Harris Jul 8, 2022
797dae9
simplify project structure docs
Rich-Harris Jul 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions documentation/docs/01-project-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Project Structure
---

A typical SvelteKit project looks like this:

```bash
my-project/
├ src/
│ ├ lib/
│ │ └ [your lib files]
│ ├ params/
│ │ └ [your param matchers]
│ ├ routes/
│ │ └ [your routes]
│ ├ app.html
│ └ hooks.js
├ static/
│ └ [your static assets]
├ package.json
├ svelte.config.js
├ tsconfig.json
└ vite.config.js
```

You'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc` and `.eslintrc.cjs` and so on, if you chose those options when running `npm create svelte`).

### Project files

#### src

The `src` directory contains the meat of your project.

- `lib` contains your library code, which can be imported via the [`$lib`](/docs/modules#$lib) alias, or packaged up for distribution using [`svelte-kit package`](/docs/packaging)
- `params` contains any [param matchers](/docs/routing#advanced-routing-matching) your app needs
- `routes` contains the [pages](/docs/routing#pages) and [endpoints](/docs/routing#endpoints) of your application
- `app.html` is your page template — an HTML document containing the following placeholders:
- `%sveltekit.head%` — `<link>` and `<script>` elements needed by the app, plus any `<svelte:head>` content
- `%sveltekit.body%` — the markup for a rendered page
- `%sveltekit.assets%` — a relative path from the page to [`paths.assets`](/docs/configuration#paths)
- `%sveltekit.nonce%` — a [CSP](/docs/configuration#csp) nonce for manually included links and scripts, if used
- `hooks.js` (optional) contains your application's [hooks](/docs/hooks)
- `service-worker.js` (optional) contains your [service worker](/docs/service-workers)

You can use `.ts` files instead of `.js` files, if using TypeScript.

#### static

Any static assets that should be served as-is, like `robots.txt` or `favicon.png`, go in here.

#### package.json

Your `package.json` file must include `@sveltejs/kit`, `svelte` and `vite` as `devDependencies`.

When you create a project with `npm create svelte`, you'll also notice that `package.json` includes `"type": "module"`. This means that `.js` files are interpreted as native JavaScript modules with `import` and `export` keywords. Legacy CommonJS files need a `.cjs` file extension.

#### svelte.config.js

This file contains your Svelte and SvelteKit [configuration](/docs/configuration).

#### tsconfig.json

This file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npm create svelte`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`.

#### vite.config.js

A SvelteKit project is really just a [Vite](https://vitejs.dev) project that uses the [`@sveltejs/kit/vite`](/docs/modules#sveltejs-kit-vite) plugin, along with any other [Vite configuration](https://vitejs.dev/config/).

### Other files

#### test

If you choose to add tests during `npm create svelte`, they will go in a `test` directory.

#### .svelte-kit

As you develop and build your project, SvelteKit will generate files in a `.svelte-kit` directory (configurable as [`outDir`](/docs/configuration#outdir)). You can ignore its contents, and delete them at any time (they will be regenerated when you next `dev` or `build`).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.