-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: open file inspector #322
Conversation
…ging; update browser select for testing
…ility options for toggle, docs
… a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good 👍 Works well locally for me.
The only small quirk so far is that on macos, using holdMode: true
, ctrl-shift
doesn't really work as ctrl-click
is considered a right click and it doesn't look like it can be prevented. Maybe we can set meta-shift
as the default for macos, rest be ctrl-shift
for a nicer experience.
Fixes #381 There have been two changes in @sveltejs/vite-plugin-svelte that cause problems for us, which this PR addresses: - https://github.com/sveltejs/vite-plugin-svelte/releases/tag/%40sveltejs%2Fvite-plugin-svelte%401.0.0-next.42 started to merge the `svelte.config.js` file [by default](sveltejs/vite-plugin-svelte#317), which may not be what storybook users want / expect, since their production config may be different from the storybook config (same reason we don't automatically merge `vite.config.js`). With the changes here, the `configFile` option in `svelteOptions` can still be set to `true` or to a specific file, if desired. - https://github.com/sveltejs/vite-plugin-svelte/releases/tag/%40sveltejs%2Fvite-plugin-svelte%401.0.0-next.43 began [returning an array of plugins](sveltejs/vite-plugin-svelte#322) rather than just a single one. This would normally be fine, except that we hack around with the plugin to create two separate ones, with different names, to avoid HMR in story files. So, this PR checks to see if the result is an array or not, and reacts accordingly. Note, I'm throwing away the inspector for story files. This might be a problem, but until we hear about it, I think this'll be fine. The inspector is still pretty experimental anyway, from what I can tell. To test, you can revert the changes I've made in `vite-config.ts`, and you'll see that the `svelte` example breaks (I updated the svelte plugin in it). With the changes, it builds successfully. This also enables the use of the new experimental inspection plugin.  To enable this feature, be sure you have `@sveltejs/vite-plugin-svelte` version `1.0.0-next.43` or higher, then add the following to your `svelteOptions` in `.storybook/main.js`: ```js module.exports = { // ... rest of config framework: '@storybook/svelte', svelteOptions: { preprocess: preprocess(), experimental: { inspector: true }, // <-- this line }, }; ``` Then, when the storybook opens, focus a story iframe and press cmd+shift (mac) or ctrl+shift (windows) to activate.
Inspired by vite-plugin-vue-inspector and it's svelte sibling https://github.com/tanhauhau/vite-plugin-svelte-inspector, this PR bakes it into vite-plugin-svelte as an experimental option.
To use it, set
experimental:{inspector: true}
either inline on vite-plugin-svelte definition or in your svelte config.Use custom
InspectorOptions
to customize it's behavior