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.

Stoybook UI loads instantly but the content takes forever to load

See original GitHub issue

Running -

{ 
  "storybook-builder-vite": "0.1.10",
  "vite": "2.6.14"
}

After I run yarn storybook the pages loads instantly, but then, it takes several minutes for it to actually show anything. in the logs, I get a lot of -

10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/doctrine.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/react-is.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/@base2_pretty-print-object.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/memoizerific.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/lodash_mapValues.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/lodash_pick.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/synchronous-promise.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/lodash_isPlainObject.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/lodash_pickBy.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/lodash_startCase.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/slash.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/stable.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/fast-deep-equal.js?v=b1467143. 10:29:00 AM [vite] Failed to load source map for /node_modules/.vite/uuid-browser_v4.js?v=b1467143.

After it actually starts working, I don’t get instant feedback on every change. Instead of doing HMR, it reloads the entire story.

my vite.config.js -

  export default defineConfig({
  plugins: [
    react({ }),
  ],
});

also tried -

export default defineConfig({
  plugins: [
    react({
      exclude: /\.stories\.(t|j)sx?$/,
    }),
  ],
});

and had the config from previous version -

import reactRefresh from '@vitejs/plugin-react-refresh';

export default {
  server: {
    plugins: [reactRefresh()],
  }
};

All behave the same.

Would love some help with that please. In other projects it works fine. Not sure what am I missing.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Ox24commented, Dec 23, 2021

Hey guys, thx to @IanVS i was able to fix it.

After starting storybook i got this message: 10:43:34 PM [vite] new dependencies found: history, preact, @mdx-js/preact, @storybook/addon-docs/blocks, updating... This caused storybook not to load properly. To fix this i added optimizeDeps to the viteFinal with my stories as entries and optimizeDeps.include the dependencies from above. The final result is this:

  viteFinal: async (config) => {
    return {
      ...config,
      optimizeDeps: {
        ...config.optimizeDeps,
        // Entries are specified relative to the root
        entries: [`${path.relative(config.root, path.resolve(__dirname, '../src'))}/**/*.stories.tsx`],
        include: [...(config.optimizeDeps?.include ?? []), "history", "preact", "@mdx-js/preact", "@storybook/addon-docs/blocks"],
      },
    };
  },
2reactions
bertybotcommented, Dec 8, 2021

Hey guys, thx to @IanVS i was able to fix it.

After starting storybook i got this message: 10:43:34 PM [vite] new dependencies found: history, preact, @mdx-js/preact, @storybook/addon-docs/blocks, updating... This caused storybook not to load properly. To fix this i added optimizeDeps to the viteFinal with my stories as entries and optimizeDeps.include the dependencies from above. The final result is this:

  viteFinal: async (config) => {
    return {
      ...config,
      resolve: {
        ...config.resolve,
      },
      optimizeDeps: {
        ...config.optimizeDeps,
        // Entries are specified relative to the root
        entries: [`${path.relative(config.root, path.resolve(__dirname, '../src'))}/**/*.stories.tsx`],
        include: [...config.optimizeDeps.include, "history", "preact", "@mdx-js/preact", "@storybook/addon-docs/blocks"],
      },
    };
  },

Works great good job dudes! I did have to do some super lazy null coalescing to get the prod build to work ...(config?.optimizeDeps?.include ?? [])

Please excuse the laziness

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting storybook takes very long · Issue #3968 - GitHub
It works fast in case of having one or two simple stories, but adding about 10 leads to start up time about 3-4...
Read more >
How to troubleshoot storybook not loading stories?
Resave save the story file. It makes the component reappear in side panel, and then you can see the errors ...
Read more >
Storybook Lazy Compilation for Webpack - JS.ORG
Lazy compilation of stories​​ Storybook uses Webpack to lazily generate the story bundles. Starting Storybook boots it up quickly as it only has ......
Read more >
Play function - Storybook - JS.ORG
When Storybook loads the story and the function executes, it interacts with the component and triggers the button click, similar to what a...
Read more >
Story rendering - Storybook
In Storybook, your stories render in a particular “preview” iframe (Canvas tab) inside the larger Storybook web application.
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