Skip to content

Commit 171fbfb

Browse files
dominikgdummdidumm
andauthored
chore: update docs (#1170)
* docs: remove cjs config documentation, mention ts extensions * add missing options, improve language * Update docs/config.md Co-authored-by: Simon H <[email protected]> * Update docs/config.md --------- Co-authored-by: Simon H <[email protected]>
1 parent 666dc61 commit 171fbfb

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

docs/config.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Besides inline options in Vite config, `vite-plugin-svelte` will also automatica
2323

2424
- `svelte.config.js`
2525
- `svelte.config.mjs`
26-
- `svelte.config.cjs`
26+
- `svelte.config.ts`
27+
- `svelte.config.mts`
2728

2829
To set a specific config file, use the `configFile` inline option. The path can be absolute or relative to the [Vite root](https://vitejs.dev/config/#root). For example:
2930

@@ -43,7 +44,7 @@ A basic Svelte config looks like this:
4344
```js
4445
// svelte.config.js
4546
export default {
46-
// svelte options
47+
// Svelte options
4748
extensions: ['.svelte'],
4849
compilerOptions: {},
4950
preprocess: [],
@@ -59,10 +60,10 @@ export default {
5960

6061
### Config file extension
6162

62-
Depending on Node's mode, make sure you're using the correct extension and syntax so it can be resolved safely.
63+
The Svelte config should always be written in ESM syntax. Depending on Node's mode, make sure you're using the correct extension.
6364

64-
- If `type: "module"` is defined in `package.json`, using `.js` only allows ESM code. Use `.cjs` to allow CJS code.
65-
- If `type: "module"` is not defined, using `.js` only allows CJS code. Use `.mjs` to allows ESM code.
65+
- If `type: "module"` is defined in `package.json`, prefer `.js` or `.ts`
66+
- If `type: "module"` is not defined, use `.mjs` or `.mts`
6667

6768
> Try to stick with the `.js` extension whenever possible.
6869
@@ -76,7 +77,7 @@ export default defineConfig({
7677
plugins: [
7778
svelte({
7879
configFile: false
79-
// your svelte config here
80+
// your Svelte config here
8081
})
8182
]
8283
});
@@ -157,12 +158,14 @@ These options are specific to the Vite plugin itself.
157158
### include
158159

159160
- **Type:** `string | string[]`
161+
- **Default:** unset
160162

161-
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on. By default, all svelte files are included.
163+
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on **in addition** to the files ending with one of the configured extensions.
162164

163165
### exclude
164166

165167
- **Type:** `string | string[]`
168+
- **Default:** unset
166169

167170
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin. By default, no files are ignored.
168171

@@ -215,7 +218,7 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
215218
- **Type:** `InspectorOptions | boolean`
216219
- **Default:** `unset` for dev, always `false` for build
217220

218-
Set to `true` or options object to enable svelte inspector during development. See the [inspector docs](./inspector.md) for the full configuration options.
221+
Set to `true` or options object to enable Svelte inspector during development. See the [inspector docs](./inspector.md) for the full configuration options.
219222

220223
Inspector mode shows you the file location where the element under cursor is defined and you can click to quickly open your code editor at this location.
221224

@@ -308,7 +311,7 @@ export default {
308311
normalizedFilename: string;
309312
timestamp: number;
310313
warnings: Warning[]; // allWarnings filtered by warnings where onwarn did not call the default handler
311-
allWarnings: Warning[]; // includes warnings filtered by onwarn and our extra vite plugin svelte warnings
314+
allWarnings: Warning[]; // includes warnings filtered by onwarn and our extra vite-plugin-svelte warnings
312315
rawWarnings: Warning[]; // raw compiler output
313316
};
314317
```
@@ -318,4 +321,18 @@ export default {
318321
- **Type** `boolean`
319322
- **Default:** `false`
320323

321-
disable svelte resolve warnings. Note: this is highly discouraged and you should instead fix these packages which will break in the future.
324+
disable Svelte resolve warnings. Note: this is highly discouraged and you should instead fix these packages which will break in the future.
325+
326+
### disableApiSveltePreprocessWarnings
327+
328+
- **Type** `boolean`
329+
- **Default:** `false`
330+
331+
disable api.sveltePreprocess deprecation warnings
332+
333+
### compileModule
334+
335+
- **Type** `CompileModuleOptions`
336+
- **Default:** `undefined`
337+
338+
set custom compile options for compilation of Svelte modules (`.svelte.js` files).

0 commit comments

Comments
 (0)