diff options
author | 2023-01-04 02:24:49 +0800 | |
---|---|---|
committer | 2023-01-03 13:24:49 -0500 | |
commit | f6cf92b48317a19a3840ad781b77d6d3cae143bb (patch) | |
tree | c22d07726672c36ba35a69285c1ad98e8d62e28c /packages/integrations/svelte/src | |
parent | 5007bc78815ce81e91c9b1482c1b84e1214de4b0 (diff) | |
download | astro-f6cf92b48317a19a3840ad781b77d6d3cae143bb.tar.gz astro-f6cf92b48317a19a3840ad781b77d6d3cae143bb.tar.zst astro-f6cf92b48317a19a3840ad781b77d6d3cae143bb.zip |
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
Diffstat (limited to 'packages/integrations/svelte/src')
-rw-r--r-- | packages/integrations/svelte/src/index.ts | 28 |
1 files changed, 6 insertions, 22 deletions
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<Options> = { 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, }), }); }, |