Skip to content
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: skip reading config file with inline option #317

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

dominikg
Copy link
Member

useful for frameworks like sveltekit that already read the config to avoid doing duplicate work.

@dominikg dominikg merged commit 10d02a8 into main Apr 27, 2022
@dominikg dominikg deleted the feat/dont-read-config branch April 27, 2022 11:29
@github-actions github-actions bot mentioned this pull request Apr 27, 2022
IanVS added a commit to storybookjs/builder-vite that referenced this pull request May 18, 2022
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.

![image](https://user-images.githubusercontent.com/4616705/169103606-d04db266-5025-4e9d-8062-f894323adf77.png)

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.
@github-actions github-actions bot mentioned this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants