Skip to content

Commit

Permalink
Improve Svelte README (#5923)
Browse files Browse the repository at this point in the history
* First stylistic pass

* Rework for x/o instead of and

* fix typo

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Add changeset

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
delucis and sarah11918 authored Jan 21, 2023
1 parent f27bb3d commit f32bf07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-ants-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/svelte": patch
---

Improve README
21 changes: 10 additions & 11 deletions packages/integrations/svelte/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss

## Options

This integration is powered by `@sveltejs/vite-plugin-svelte`. To customize the Svelte compiler, options can be provided to the integration. See the `@sveltejs/vite-plugin-svelte` [docs](https://github.com/sveltejs/vite-plugin-svelte/blob/HEAD/docs/config.md) for more details.
This integration is powered by `@sveltejs/vite-plugin-svelte`. To customize the Svelte compiler, options can be provided to the integration. See the [`@sveltejs/vite-plugin-svelte` docs](https://github.com/sveltejs/vite-plugin-svelte/blob/HEAD/docs/config.md) for more details.

### Default options

A few of the default options passed to the Svelte compiler are required to build properly for Astro and cannot be overridden.
This integration passes the following default options to the Svelte compiler:

```js
const defaultOptions = {
Expand All @@ -88,40 +88,39 @@ const defaultOptions = {
};
```

The `emitCss`, `compilerOptions.dev`, and `compilerOptions.hydratable` cannot be overridden.
These `emitCss`, `compilerOptions.dev`, and `compilerOptions.hydratable` values are required to build properly for Astro and cannot be overridden.

Providing your own `preprocess` options **will** override the defaults - make sure to enable the preprocessor flags needed for your project. For example,
Providing your own `preprocess` options **will** override the [`vitePreprocess()`](https://github.com/sveltejs/vite-plugin-svelte/blob/HEAD/docs/preprocess.md) default. Make sure to enable the preprocessor flags needed for your project.

You can set options either by passing them to the `svelte` integration in `astro.config.mjs` or in `svelte.config.js`. Either of these would override the default `preprocess` setting:

```js
// astro.config.js
// astro.config.mjs
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:
If you're using a preprocessor like TypeScript or SCSS in your Svelte files, you can create a `svelte.config.js` file so that the Svelte IDE extension can correctly parse the Svelte files.

```js
// svelte.config.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`.
This config file will be automatically added for you when you run `astro add svelte`.

0 comments on commit f32bf07

Please sign in to comment.