Move to new Svelte release

This commit is contained in:
Filip Krumpe 2024-05-28 21:02:27 +02:00
commit 2c87b8dde1
27 changed files with 5585 additions and 6263 deletions

13
webapp/.eslintignore Normal file
View File

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -1,15 +1,31 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
plugins: ['svelte3'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
}
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

6
webapp/.gitignore vendored
View File

@ -1,8 +1,10 @@
.DS_Store
node_modules
build/
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

4
webapp/.prettierignore Normal file
View File

@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@ -2,5 +2,16 @@
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}
"printWidth": 100,
"plugins": [
"prettier-plugin-svelte"
],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}

View File

@ -1,6 +1,6 @@
# create-svelte
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
## Creating a project
@ -8,14 +8,12 @@ If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npm init svelte@next
npm create svelte@latest
# create a new project in my-app
npm init svelte@next my-app
npm create svelte@latest my-app
```
> Note: the `@next` is temporary
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
@ -29,10 +27,12 @@ npm run dev -- --open
## Building
Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:
To create a production version of your app:
```bash
npm run build
```
> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
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.

11506
webapp/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,39 @@
{
"name": "webapp",
"version": "0.0.1",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-static": "^1.0.0-next.26",
"@sveltejs/kit": "next",
"autoprefixer": "^10.4.2",
"cssnano": "^5.0.15",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^3.2.1",
"postcss": "^8.4.5",
"prettier": "^2.4.1",
"prettier-plugin-svelte": "^2.4.0",
"svelte": "^3.44.0",
"svelte-preprocess": "^4.10.1",
"tailwindcss": "^3.0.13"
},
"type": "module"
"name": "webapp",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"autoprefixer": "^10.4.19",
"cssnano": "^7.0.1",
"postcss": "^8.4.38"
}
}

13
webapp/src/app.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
export {};

View File

@ -1,13 +1,15 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<link rel="icon" href="%svelte.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%svelte.head%
</head>
<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<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>
</html>

1
webapp/src/lib/index.ts Normal file
View File

@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.

View File

Before

Width:  |  Height:  |  Size: 111 B

After

Width:  |  Height:  |  Size: 111 B

View File

@ -0,0 +1,16 @@
<script>
import Logo from './Logo.svelte';
import Hamburger from './Hamburger.svelte';
import Menu from './Menu.svelte';
export let sidebar = false;
</script>
<header class="flex justify-between bg-gray-200 p-2 items-center text-gray-600 border-b-2">
<nav class="flex">
<Hamburger bind:open={sidebar} />
<Logo />
</nav>
<Menu />
</header>

View File

@ -0,0 +1,26 @@
<script>
import Navbar from '$lib/menu/Navbar.svelte';
import Sidebar from '$lib/menu/Sidebar.svelte';
import '../app.css';
let open = false;
</script>
<main class="w-full h-full">
<Sidebar bind:open />
<Navbar bind:sidebar={open} />
<slot></slot>
</main>
<style>
:global(body) {
padding: 0;
}
@media (min-width: 640px) {
main {
max-width: none;
}
}
</style>

View File

@ -0,0 +1 @@
export const prerender = true;

View File

@ -0,0 +1,4 @@
<main class="w-full h-full">
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
</main>

View File

@ -1,15 +0,0 @@
<main class="p-4 text-gray-300">
<svg height="100%" width="100%">
<line x1=0 y1=4 x2=400 y2=4/>
<line x1=0 y1=34 x2=200 y2=34/>
<line x1=0 y1=64 x2=300 y2=64/>
<line x1=0 y1=94 x2=280 y2=94/>
</svg>
</main>
<style>
svg line {
stroke: currentColor;
stroke-width: 12;
}
</style>

View File

@ -1,26 +0,0 @@
<script>
import Navbar from "./menu/_Navbar.svelte";
import Sidebar from "./menu/_Sidebar.svelte";
import "../app.css";
let open = false;
</script>
<main class="w-full h-full">
<Sidebar bind:open/>
<Navbar bind:sidebar={open}/>
<slot></slot>
</main>
<style>
:global(body) {
padding: 0;
}
@media (min-width: 640px) {
main {
max-width: none;
}
}
</style>

View File

@ -1,10 +0,0 @@
<script>
import Main from "./_Main.svelte";
</script>
<main class="w-full h-full">
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<Main/>
</main>

View File

@ -1,16 +0,0 @@
<script>
import Logo from './_Logo.svelte';
import Hamburger from './_Hamburger.svelte';
import Menu from './_Menu.svelte';
export let sidebar = false;
</script>
<header class="flex justify-between bg-gray-200 p-2 items-center text-gray-600 border-b-2">
<nav class="flex">
<Hamburger bind:open={sidebar}/>
<Logo/>
</nav>
<Menu/>
</header>

View File

@ -1,18 +1,17 @@
import adapter from "@sveltejs/adapter-static";
import preprocess from "svelte-preprocess";
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [
preprocess({
postcss: true,
}),
],
kit: {
adapter: adapter(),
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte'
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
}
};

19
webapp/tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by 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
}

6
webapp/vite.config.ts Normal file
View File

@ -0,0 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
});