diff --git a/.changeset/tame-cups-end.md b/.changeset/tame-cups-end.md new file mode 100644 index 000000000..6a456a325 --- /dev/null +++ b/.changeset/tame-cups-end.md @@ -0,0 +1,5 @@ +--- +'houdini': patch +--- + +Update init command to work with latest file template diff --git a/src/cmd/init.ts b/src/cmd/init.ts index e4c56059f..900dc3a3a 100644 --- a/src/cmd/init.ts +++ b/src/cmd/init.ts @@ -154,7 +154,7 @@ export default async function init( } else if (framework === 'svelte') { await updateSvelteMainJs(targetPath) } - await updateViteConfig(targetPath, framework) + await updateViteConfig(targetPath, framework, typescript) await tjsConfig(targetPath, framework) // we're done! @@ -300,8 +300,12 @@ async function tjsConfig(targetPath: string, framework: 'kit' | 'svelte') { return false } -async function updateViteConfig(targetPath: string, framework: 'kit' | 'svelte') { - const viteConfigPath = path.join(targetPath, 'vite.config.js') +async function updateViteConfig( + targetPath: string, + framework: 'kit' | 'svelte', + typescript: boolean +) { + const viteConfigPath = path.join(targetPath, 'vite.config' + typescript ? '.ts' : '.js') const oldViteConfig1 = `import { sveltekit } from '@sveltejs/kit/vite'; @@ -313,13 +317,15 @@ const config = { export default config; ` - const oldViteConfig2 = `import { defineConfig } from 'vite' -import { svelte } from '@sveltejs/vite-plugin-svelte' + const oldViteConfig2 = `import { sveltekit } from '@sveltejs/kit/vite'; +import type { UserConfig } from 'vite'; + +const config: UserConfig = { + plugins: [sveltekit()] +}; + +export default config; -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [svelte()] -}) ` const viteConfigKit = `import { sveltekit } from '@sveltejs/kit/vite';