Change default main.js config for svelte project
See original GitHub issueCurrently, when installing storybook in a svelte project, it’s not possible to import an external svelte component. The following error occurs:
Module not found: Error: Can't resolve .......
To Reproduce
Just import an external library that relies on the “svelte” entry.
In my situation, I tried to use svelte-loading-skeleton
Additional context As mentioned here https://github.com/storybookjs/storybook/issues/9542 the solution is to add this
webpackFinal(config) {
return {
...config,
resolve: {
...config.resolve,
mainFields: ['svelte', 'browser', 'module', 'main']
}
}
}
to the main.js file.
But it doesn’t make sense in my opinion not to have that by default when you use svelte. (I used npx sb init to install storybook on my existing project).
So my request is to add that snippet (or something that fix this issue) by default when using npx sb init on a svelte project.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Configuration • Docs • SvelteKit
Your project's configuration lives in a svelte.config.js file at the root of your project. As well as SvelteKit, this config object is used...
Read more >Getting started with Svelte - Learn web development | MDN
Web developers with basic HTML, CSS, and JavaScript knowledge can easily grasp Svelte specifics in a short time and start building web ...
Read more >How to Set Up a Svelte App with Rollup | TypeOfNaN
This post gives the basics on how to build Svelte apps for development and production using Rollup.
Read more >Setting up SvelteKit with Storybook - Daniel Imfeld
Summing It Up · Rename .storybook/main.js to .storybook/main. · Remove references in main.cjs to svelte.config.js . · Use Storybook's webpack 5 ...
Read more >Creating your first Svelte App with SvelteKit - Fjolt
These are all included by default in adapter-auto - so only change your svelte.config.js file if you aren't planning on using a Node....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-rc.0 containing PR #14235 that references this issue. Upgrade today to the
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
this belong to the default svelte webpack preset, imo. It’s implemented in the linked PR.