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

fix(#27): sveltekit route is not always defined #30

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions apps/sveltekit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ node_modules
.env
.env.*
!.env.example
.vercel
.output
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.vercel
45 changes: 12 additions & 33 deletions apps/sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
# create-svelte
# Sveltekit Demo application for Vercel Speed-insights

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
## Setup

## Creating a project
This application was created with the following commands:

If you're seeing this, you've probably already done this step. Congrats!
- `cd apps`
- `pnpm create svelte@latest sveltekit` (answers: Skeleton project, JavaScript with JSDoc, no additional option)
- `cd sveltekit`
- add `src/+layout.js` to include `import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit'; injectSpeedInsights();`
- edit package.json to add `"@vercel/speed-insights": "workspace:*"` dependency and change `@sveltejs/adapter-auto` into `@sveltejs/adapter-vercel`
- eddi `svelte.config.js` to change `@sveltejs/adapter-auto` into `@sveltejs/adapter-vercel`
- `pnpm i`

```bash
# create a new project in the current directory
npm create svelte@latest
## Usage

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
Start it with `cd apps/sveltekit` + `pnpm dev` and browse to [http://localhost:5173](http://localhost:5173)
5 changes: 3 additions & 2 deletions apps/sveltekit/tsconfig.json → apps/sveltekit/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias and https://kit.svelte.dev/docs/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
Expand Down
21 changes: 8 additions & 13 deletions apps/sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"name": "svelte",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"dev": "vite dev",
"preview": "vite preview"
},
"dependencies": {
"@vercel/speed-insights": "workspace:*"
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@types/cookie": "^0.5.1",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
"@sveltejs/adapter-vercel": "^3.1.0",
"@sveltejs/kit": "^1.27.4",
"@vercel/speed-insights": "workspace:*",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"typescript": "^5.0.0",
"vite": "^4.4.2"
}
Expand Down
1 change: 1 addition & 0 deletions apps/sveltekit/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>

<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
Expand Down
16 changes: 0 additions & 16 deletions apps/sveltekit/src/lib/images/github.svg

This file was deleted.

1 change: 0 additions & 1 deletion apps/sveltekit/src/lib/images/svelte-logo.svg

This file was deleted.

Binary file removed apps/sveltekit/src/lib/images/svelte-welcome.png
Binary file not shown.
Binary file removed apps/sveltekit/src/lib/images/svelte-welcome.webp
Binary file not shown.
3 changes: 3 additions & 0 deletions apps/sveltekit/src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';

injectSpeedInsights();
57 changes: 0 additions & 57 deletions apps/sveltekit/src/routes/+layout.svelte

This file was deleted.

61 changes: 2 additions & 59 deletions apps/sveltekit/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,59 +1,2 @@
<script>
import Counter from './Counter.svelte';
import welcome from '$lib/images/svelte-welcome.webp';
import welcome_fallback from '$lib/images/svelte-welcome.png';
</script>

<svelte:head>
<title>Home</title>
<meta name="description" content="Svelte demo app" />
</svelte:head>

<section>
<h1>
<span class="welcome">
<picture>
<source srcset={welcome} type="image/webp" />
<img src={welcome_fallback} alt="Welcome" />
</picture>
</span>

to your new<br />SvelteKit app
</h1>

<h2>
try editing <strong>src/routes/+page.svelte</strong>
</h2>

<Counter />
</section>

<style>
section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 0.6;
}
h1 {
width: 100%;
}
.welcome {
display: block;
position: relative;
width: 100%;
height: 0;
padding: 0 0 calc(100% * 495 / 2048) 0;
}
.welcome img {
position: absolute;
width: 100%;
height: 100%;
top: 0;
display: block;
}
</style>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="/bruno">this page</a> to know more...</p>
3 changes: 0 additions & 3 deletions apps/sveltekit/src/routes/+page.ts

This file was deleted.

102 changes: 0 additions & 102 deletions apps/sveltekit/src/routes/Counter.svelte

This file was deleted.

Loading