@astrojs/svelte
Advanced tools
Comparing version 0.1.4 to 0.1.5
# @astrojs/svelte | ||
## 0.1.5 | ||
### Patch Changes | ||
- [#3685](https://github.com/withastro/astro/pull/3685) [`3d554fdb`](https://github.com/withastro/astro/commit/3d554fdbfb49d85d2945b7775825f7d9ace959ce) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix PostCSS config not applied to Svelte component by default | ||
## 0.1.4 | ||
@@ -4,0 +10,0 @@ |
@@ -0,5 +1,5 @@ | ||
import type { Options } from '@sveltejs/vite-plugin-svelte'; | ||
import type { AstroIntegration } from 'astro'; | ||
import type { Options } from '@sveltejs/vite-plugin-svelte'; | ||
declare type OptionsCallback = (defaultOptions: Options) => Options; | ||
export default function (options?: Options | OptionsCallback): AstroIntegration; | ||
export {}; |
@@ -29,3 +29,7 @@ var __defProp = Object.defineProperty; | ||
} | ||
function getViteConfiguration(isDev, options) { | ||
function getViteConfiguration({ | ||
options, | ||
postcssConfig, | ||
isDev | ||
}) { | ||
const defaultOptions = { | ||
@@ -37,2 +41,3 @@ emitCss: true, | ||
less: true, | ||
postcss: postcssConfig, | ||
sass: { renderSync: true }, | ||
@@ -68,5 +73,11 @@ scss: { renderSync: true }, | ||
hooks: { | ||
"astro:config:setup": ({ command, updateConfig, addRenderer }) => { | ||
"astro:config:setup": ({ command, updateConfig, addRenderer, config }) => { | ||
addRenderer(getRenderer()); | ||
updateConfig({ vite: getViteConfiguration(command === "dev", options) }); | ||
updateConfig({ | ||
vite: getViteConfiguration({ | ||
options, | ||
isDev: command === "dev", | ||
postcssConfig: config.style.postcss | ||
}) | ||
}); | ||
} | ||
@@ -73,0 +84,0 @@ } |
{ | ||
"name": "@astrojs/svelte", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Use Svelte components within Astro", | ||
@@ -29,3 +29,3 @@ "type": "module", | ||
"dependencies": { | ||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.45", | ||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.47", | ||
"postcss-load-config": "^3.1.4", | ||
@@ -36,3 +36,3 @@ "svelte-preprocess": "^4.10.6", | ||
"devDependencies": { | ||
"astro": "1.0.0-beta.38", | ||
"astro": "1.0.0-beta.53", | ||
"astro-scripts": "0.0.4", | ||
@@ -39,0 +39,0 @@ "svelte": "^3.48.0" |
@@ -1,5 +0,6 @@ | ||
import type { AstroIntegration, AstroRenderer } from 'astro'; | ||
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 type { Options } from '@sveltejs/vite-plugin-svelte'; | ||
import type { UserConfig } from 'vite'; | ||
@@ -14,4 +15,14 @@ function getRenderer(): AstroRenderer { | ||
function getViteConfiguration(isDev: boolean, options?: Options | OptionsCallback) { | ||
const defaultOptions = { | ||
type ViteConfigurationArgs = { | ||
isDev: boolean; | ||
options?: Options | OptionsCallback; | ||
postcssConfig: AstroConfig['style']['postcss']; | ||
}; | ||
function getViteConfiguration({ | ||
options, | ||
postcssConfig, | ||
isDev, | ||
}: ViteConfigurationArgs): UserConfig { | ||
const defaultOptions: Partial<Options> = { | ||
emitCss: true, | ||
@@ -22,2 +33,3 @@ compilerOptions: { dev: isDev, hydratable: true }, | ||
less: true, | ||
postcss: postcssConfig, | ||
sass: { renderSync: true }, | ||
@@ -66,5 +78,11 @@ scss: { renderSync: true }, | ||
// Anything that gets returned here is merged into Astro Config | ||
'astro:config:setup': ({ command, updateConfig, addRenderer }) => { | ||
'astro:config:setup': ({ command, updateConfig, addRenderer, config }) => { | ||
addRenderer(getRenderer()); | ||
updateConfig({ vite: getViteConfiguration(command === 'dev', options) }); | ||
updateConfig({ | ||
vite: getViteConfiguration({ | ||
options, | ||
isDev: command === 'dev', | ||
postcssConfig: config.style.postcss, | ||
}), | ||
}); | ||
}, | ||
@@ -71,0 +89,0 @@ }, |
18121
228