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
feat: svelte inspector updates and promote from experimental (#631)
* fix(inspector): move inspector host out of body to decrease risk of it getting removed by something overwriting body content
* feat(inspector): promote from experimental to regular, warn users to update config
* feat(inspector): enable inspector by default
* feat(inspector): enable holdMode by default
* fix(inspector): automatically disable on leave after a file has been opened
* fix(inspector): prepend vite base when calling __openInEditor
* feat(inspector): allow configuration via environment
* fix: disable inspector in CI and use eager disable if found via env
* fix: revert previous change, fix testcase and make sure inspector is only enabled for devserver
* fix: don't enable inspector by default
* fix(inspector): return void if no environment option is set
* fix: remove extra check for serve mode, it is already covered by apply: serve
* fix(inspector): remove keyup listener on destroy
* inspector is automatically disabled when releasing toggleKeyCombo after holding it for a longpress
321
-
* @defaultfalse
256
+
* @defaulttrue
322
257
*/
323
258
holdMode?:boolean;
324
259
@@ -341,9 +276,94 @@ export default {
341
276
}
342
277
```
343
278
344
-
Set to `true` or customized `InspectorOptions` to enable svelte inspector during development.
279
+
Set to `true` or options object to enable svelte inspector during development.
280
+
281
+
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.
282
+
283
+
**Example:**
284
+
285
+
```js
286
+
// vite.config.js
287
+
exportdefaultdefineConfig({
288
+
plugins: [
289
+
svelte({
290
+
inspector: {
291
+
toggleKeyCombo:'meta-shift',
292
+
holdMode:true,
293
+
showToggleButton:'always',
294
+
toggleButtonPos:'bottom-right'
295
+
}
296
+
})
297
+
]
298
+
});
299
+
```
300
+
301
+
#### Customizing Inspector options via environment
302
+
303
+
Svelte Inspector toggle keys and other options are personal preferences. As such it isn't always convenient to define them in a shared svelte config file.
304
+
To allow you to use your own setup, svelte inspector can be configured via environment variables, both from shell and dotenv files.
305
+
306
+
```shell
307
+
# just keycombo, unquoted string
308
+
SVELTE_INSPECTOR_TOGGLE=control-shift
309
+
310
+
# options object as json, all options except appendTo are supported
When enabled, 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.
320
+
> Inspector options set on the environment take precedence over values set in svelte config and automatically enable svelte inspector during dev.
321
+
322
+
## Experimental options
323
+
324
+
These options are considered experimental and breaking changes to them can occur in any release! Specify them under the `experimental` option.
325
+
326
+
Either in Vite config:
327
+
328
+
```js
329
+
// vite.config.js
330
+
exportdefaultdefineConfig({
331
+
plugins: [
332
+
svelte({
333
+
experimental: {
334
+
// experimental options
335
+
}
336
+
})
337
+
]
338
+
});
339
+
```
340
+
341
+
or in Svelte config:
342
+
343
+
```js
344
+
// svelte.config.js
345
+
exportdefault {
346
+
vitePlugin: {
347
+
experimental: {
348
+
// experimental options
349
+
}
350
+
}
351
+
};
352
+
```
353
+
354
+
### dynamicCompileOptions
355
+
356
+
-**Type:**
357
+
358
+
```ts
359
+
typeDynamicCompileOptions= (data: {
360
+
filename:string; // The file to be compiled
361
+
code:string; // The preprocessed Svelte code
362
+
compileOptions:Partial<CompileOptions>; // The current compiler options
0 commit comments