From df521b0c06d6cb23fd753e52011ce585c8e8666b Mon Sep 17 00:00:00 2001 From: spiffyguy Date: Tue, 2 Jul 2024 04:32:52 -0700 Subject: [PATCH] Use the vitePreprocess() function from vite-plugin-svelte to svelte's "preprocess" parameter on build. Fixes "Unexpected token 'type'" when importing an external typescript module (in my case Uppy, https://uppy.io/docs/svelte/) --- create/templates/generate-vite-config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create/templates/generate-vite-config.js b/create/templates/generate-vite-config.js index 39a2883..74c0d94 100644 --- a/create/templates/generate-vite-config.js +++ b/create/templates/generate-vite-config.js @@ -16,7 +16,7 @@ module.exports = (options) => { `import vue from '@vitejs/plugin-vue';`, `vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('swiper-') } } }),,`, ], - svelte: [``, 'svelte(),'], + svelte: [``, 'svelte({preprocess: vitePreprocess()}),'], }; // prettier-ignore @@ -42,7 +42,7 @@ module.exports = (options) => { `)} export default async () => { ${templateIf(framework === 'svelte', () => ` - const { svelte } = await import('@sveltejs/vite-plugin-svelte'); + const { svelte, vitePreprocess } = await import('@sveltejs/vite-plugin-svelte'); `)} return { plugins: [