-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(examples): add Vite example using svelte v5
- Loading branch information
Showing
10 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# examples/vite@svelte-5 | ||
|
||
> `svelte-highlight` Vite set-up. | ||
## Available Scripts | ||
|
||
### `bun dev` | ||
|
||
Runs the project in development mode and watches for any changes. | ||
|
||
### `bun run build` | ||
|
||
Builds the project for production. | ||
|
||
### `bun preview` | ||
|
||
Preview the app locally. Run `bun run build` first. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
</head> | ||
<body> | ||
<script type="module"> | ||
import { mount } from "svelte"; | ||
import App from "./src/App.svelte"; | ||
|
||
mount(App, { target: document.body }); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/vite-plugin-svelte": "latest", | ||
"@tsconfig/svelte": "latest", | ||
"svelte": "5.0.0-next.200", | ||
"svelte-highlight": "latest", | ||
"typescript": "latest", | ||
"vite": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script lang="ts"> | ||
import { Highlight } from "svelte-highlight"; | ||
import typescript from "svelte-highlight/languages/typescript"; | ||
import atomOneDark from "svelte-highlight/styles/atom-one-dark"; | ||
import DynamicImport from "./DynamicImport.svelte"; | ||
const code = "const add = (a: number, b: number) => a + b;"; | ||
</script> | ||
|
||
<svelte:head> | ||
{@html atomOneDark} | ||
</svelte:head> | ||
|
||
<Highlight language={typescript} {code} /> | ||
|
||
<DynamicImport /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import type { HighlightAuto } from "svelte-highlight"; | ||
let component: typeof HighlightAuto; | ||
let styles: string; | ||
onMount(async () => { | ||
component = (await import("svelte-highlight")).HighlightAuto; | ||
styles = (await import("svelte-highlight/styles/atom-one-dark")).default; | ||
}); | ||
</script> | ||
|
||
<svelte:head> | ||
{#if styles} | ||
{@html styles} | ||
{/if} | ||
</svelte:head> | ||
|
||
<svelte:component | ||
this={component} | ||
langtag | ||
code={`body {\n padding: 0;\n color: red;\n}`} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="svelte" /> | ||
/// <reference types="vite/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "@tsconfig/svelte/tsconfig.json", | ||
"compilerOptions": { | ||
"strict": true | ||
}, | ||
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.svelte"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { svelte, vitePreprocess } from "@sveltejs/vite-plugin-svelte"; | ||
import type { UserConfig } from "vite"; | ||
|
||
export default { | ||
plugins: [ | ||
svelte({ | ||
preprocess: vitePreprocess(), | ||
}), | ||
], | ||
} satisfies UserConfig; |