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: add typescript support in .svelte files #277

Merged
merged 3 commits into from
Dec 31, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-typescript-in-svelte-and-sveltekit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-tauri-app": patch
---

Add `svelte-process` preprocessor to `svelte-ts` and `svelte-kit-ts` templates by default so typescript can work correctly inside `.svelte` files.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import staticAdapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/kit/vite";

/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [vitePreprocess()],
kit: {
adapter: staticAdapter(),
},
Expand Down
1 change: 1 addition & 0 deletions packages/cli/fragments/fragment-svelte-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@tsconfig/svelte": "^3.0.0",
"svelte": "^3.54.0",
"svelte-check": "^2.10.0",
"svelte-preprocess": "^5.0.0",
"tslib": "^2.4.1",
"typescript": "^4.6.4",
"vite": "^4.0.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/fragments/fragment-svelte-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import sveltePreprocess from "svelte-preprocess";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
plugins: [
svelte({
preprocess: [
sveltePreprocess({
typescript: true,
}),
],
}),
],

// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
Expand Down