diff options
author | 2023-01-19 21:13:40 +0800 | |
---|---|---|
committer | 2023-01-19 08:13:40 -0500 | |
commit | a342a486c2831461e24e6c2f1ca8a9d3e15477b6 (patch) | |
tree | 3f83bd4a36152652dc2024ece5780df77daea59a /packages/integrations/svelte/README.md | |
parent | 899214298cee5f0c975c7245e623c649e1842d73 (diff) | |
download | astro-a342a486c2831461e24e6c2f1ca8a9d3e15477b6.tar.gz astro-a342a486c2831461e24e6c2f1ca8a9d3e15477b6.tar.zst astro-a342a486c2831461e24e6c2f1ca8a9d3e15477b6.zip |
Refactor Svelte preprocess integration handling (#5901)
* Let user setup vitePreprocess
* Abstract function
* Add changeset
* Update svelte syntax
* Make fallback
* Fix docs
* Update changeset
* Fix types
Diffstat (limited to '')
-rw-r--r-- | packages/integrations/svelte/README.md | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/packages/integrations/svelte/README.md b/packages/integrations/svelte/README.md index ab6f5d856..854bded21 100644 --- a/packages/integrations/svelte/README.md +++ b/packages/integrations/svelte/README.md @@ -84,18 +84,44 @@ A few of the default options passed to the Svelte compiler are required to build const defaultOptions = { emitCss: true, compilerOptions: { dev: isDev, hydratable: true }, - preprocess: [ - preprocess({ - less: true, - sass: { renderSync: true }, - scss: { renderSync: true }, - stylus: true, - typescript: true, - }), - ], + preprocess: vitePreprocess() }; ``` The `emitCss`, `compilerOptions.dev`, and `compilerOptions.hydratable` cannot be overridden. -Providing your own `preprocess` options **will** override the defaults - make sure to enable the preprocessor flags needed for your project. +Providing your own `preprocess` options **will** override the defaults - make sure to enable the preprocessor flags needed for your project. For example, + +```js +// astro.config.js +import svelte from '@astrojs/svelte'; + +export default { + integrations: [svelte({ preprocess: [] })], +}; +``` + +and + +```js +// svelte.config.js +export default { + preprocess: [], +}; +``` + +Will override the default `preprocess` option. You can read the [`vitePreprocess` docs](https://github.com/sveltejs/vite-plugin-svelte/blob/HEAD/docs/preprocess.md) for more information of how it works. + +## Intellisense for TypeScript + +If you're using a preprocessor like TypeScript or SCSS in your Svelte files, you can create a `svelte.config.js` file with: + +```js +import { vitePreprocess } from '@astrojs/svelte'; + +export default { + preprocess: vitePreprocess(), +}; +``` + +So the Svelte IDE extension can correctly parse the Svelte files. This config file is added by default when you run `astro add svelte`. |