You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
move plugin options in svelte.config.js into "vitePlugin"
6
+
7
+
update your svelte.config.js and wrap [plugin options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#plugin-options) with `vitePlugin`
Copy file name to clipboardExpand all lines: docs/config.md
+53-27
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
`vite-plugin-svelte` accepts inline options that can be used to change its behaviour. An object can be passed to the first argument of the `svelte` plugin:
4
4
5
5
```js
6
+
// vite.config.js
6
7
exportdefaultdefineConfig({
7
8
plugins: [
8
9
svelte({
@@ -18,7 +19,7 @@ Explore the various options below!
18
19
19
20
### Config file resolving
20
21
21
-
Besides inline options, `vite-plugin-svelte` will also automatically resolve options from a Svelte config file if one exists. The default search paths are:
22
+
Besides inline options in Vite config, `vite-plugin-svelte` will also automatically resolve options from a Svelte config file if one exists. The default search paths are:
22
23
23
24
-`svelte.config.js`
24
25
-`svelte.config.mjs`
@@ -27,6 +28,7 @@ Besides inline options, `vite-plugin-svelte` will also automatically resolve opt
27
28
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:
28
29
29
30
```js
31
+
// vite.config.js
30
32
exportdefaultdefineConfig({
31
33
plugins: [
32
34
svelte({
@@ -42,12 +44,16 @@ A basic Svelte config looks like this:
42
44
// svelte.config.js
43
45
exportdefault {
44
46
// svelte options
47
+
extensions: ['.svelte'],
45
48
compilerOptions: {},
46
49
preprocess: [],
47
-
// plugin options
48
50
onwarn: (warning, handler) =>handler(warning),
49
-
// experimental options
50
-
experimental: {}
51
+
// plugin options
52
+
vitePlugin: {
53
+
exclude: [],
54
+
// experimental options
55
+
experimental: {}
56
+
}
51
57
};
52
58
```
53
59
@@ -65,6 +71,7 @@ Depending on Node's mode, make sure you're using the correct extension and synta
65
71
Use `configFile: false` to prevent `vite-plugin-svelte` from reading the config file or restarting the Vite dev server when it changes.
66
72
67
73
```js
74
+
// vite.config.js
68
75
exportdefaultdefineConfig({
69
76
plugins: [
70
77
svelte({
@@ -98,6 +105,7 @@ These options are specific to the Svelte compiler and are generally shared acros
98
105
**Example:**
99
106
100
107
```js
108
+
// vite.config.js
101
109
importsveltePreprocessfrom'svelte-preprocess';
102
110
103
111
exportdefaultdefineConfig({
@@ -109,36 +117,13 @@ These options are specific to the Svelte compiler and are generally shared acros
109
117
});
110
118
```
111
119
112
-
## Plugin options
113
-
114
-
These options are specific to the Vite plugin itself.
115
-
116
-
### include
117
-
118
-
-**Type:**`string | string[]`
119
-
120
-
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.
121
-
122
-
### exclude
123
-
124
-
-**Type:**`string | string[]`
125
-
126
-
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.
127
-
128
120
### extensions
129
121
130
122
-**Type:**`string[]`
131
123
-**Default:**`['.svelte']`
132
124
133
125
A list of file extensions to be compiled by Svelte. Useful for custom extensions like `.svg` and `.svx`.
134
126
135
-
### emitCss
136
-
137
-
-**Type:**`boolean`
138
-
-**Default:**`true`
139
-
140
-
Emit Svelte styles as virtual CSS files for Vite and other plugins to process.
@@ -163,6 +148,29 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
163
148
});
164
149
```
165
150
151
+
## Plugin options
152
+
153
+
These options are specific to the Vite plugin itself.
154
+
155
+
### include
156
+
157
+
-**Type:**`string | string[]`
158
+
159
+
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.
160
+
161
+
### exclude
162
+
163
+
-**Type:**`string | string[]`
164
+
165
+
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.
166
+
167
+
### emitCss
168
+
169
+
-**Type:**`boolean`
170
+
-**Default:**`true`
171
+
172
+
Emit Svelte styles as virtual CSS files for Vite and other plugins to process.
173
+
166
174
### hot
167
175
168
176
-**Type:**`boolean | SvelteHotOptions` - See [svelte-hmr](https://github.com/sveltejs/svelte-hmr#options)
@@ -197,7 +205,10 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
197
205
198
206
These options are considered experimental and breaking changes to them can occur in any release! Specify them under the `experimental` option.
0 commit comments