From f6cf92b48317a19a3840ad781b77d6d3cae143bb Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 Jan 2023 02:24:49 +0800 Subject: Upgrade to Vite 4 (#5685) * Upgrade Vite 4 * Simplify Svelte preprocess setup * Upgrade rollup * Fix tests * Fix wrong changeset target * Fix error tests * Set NODE_ENV default --- packages/integrations/svelte/src/index.ts | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'packages/integrations/svelte/src') diff --git a/packages/integrations/svelte/src/index.ts b/packages/integrations/svelte/src/index.ts index f162437c0..6bf5bcc4e 100644 --- a/packages/integrations/svelte/src/index.ts +++ b/packages/integrations/svelte/src/index.ts @@ -1,7 +1,6 @@ import type { Options } from '@sveltejs/vite-plugin-svelte'; -import { svelte } from '@sveltejs/vite-plugin-svelte'; -import type { AstroConfig, AstroIntegration, AstroRenderer } from 'astro'; -import preprocess from 'svelte-preprocess'; +import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte'; +import type { AstroIntegration, AstroRenderer } from 'astro'; import type { UserConfig } from 'vite'; function getRenderer(): AstroRenderer { @@ -15,27 +14,13 @@ function getRenderer(): AstroRenderer { type ViteConfigurationArgs = { isDev: boolean; options?: Options | OptionsCallback; - postcssConfig: AstroConfig['style']['postcss']; }; -function getViteConfiguration({ - options, - postcssConfig, - isDev, -}: ViteConfigurationArgs): UserConfig { +function getViteConfiguration({ options, isDev }: ViteConfigurationArgs): UserConfig { const defaultOptions: Partial = { emitCss: true, compilerOptions: { dev: isDev, hydratable: true }, - preprocess: [ - preprocess({ - less: true, - postcss: postcssConfig, - sass: { renderSync: true }, - scss: { renderSync: true }, - stylus: true, - typescript: true, - }), - ], + preprocess: [vitePreprocess()], }; // Disable hot mode during the build @@ -65,7 +50,7 @@ function getViteConfiguration({ return { optimizeDeps: { - include: ['@astrojs/svelte/client.js', 'svelte', 'svelte/internal'], + include: ['@astrojs/svelte/client.js'], exclude: ['@astrojs/svelte/server.js'], }, plugins: [svelte(resolvedOptions)], @@ -78,13 +63,12 @@ export default function (options?: Options | OptionsCallback): AstroIntegration name: '@astrojs/svelte', hooks: { // Anything that gets returned here is merged into Astro Config - 'astro:config:setup': ({ command, updateConfig, addRenderer, config }) => { + 'astro:config:setup': ({ command, updateConfig, addRenderer }) => { addRenderer(getRenderer()); updateConfig({ vite: getViteConfiguration({ options, isDev: command === 'dev', - postcssConfig: config.style.postcss, }), }); }, -- cgit v1.2.3