question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change default main.js config for svelte project

See original GitHub issue

Currently, 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Mar 15, 2021

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 @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there’s still more to do.

1reaction
j3rem1ecommented, Mar 15, 2021

this belong to the default svelte webpack preset, imo. It’s implemented in the linked PR.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found