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.

Add support for Storybook custom builder

See original GitHub issue

Currently storybook requires either webpack or webpack5 set in the { core: { builder: '...' } }

I’ve been wanting to use more custom builder for plugins without having to fork the whole storybook integration. For example:

const rootMain = require('../../../.storybook/main');

module.exports = {
  ...rootMain,

  core: { ...rootMain.core, builder: '@storybook/builder-vite' },

  stories: [
    ...rootMain.stories,
    '../src/lib/**/*.stories.mdx',
    '../src/lib/**/*.stories.@(js|jsx|ts|tsx)',
  ],
  addons: [...rootMain.addons, '@nrwl/react/plugins/storybook'],

  async webpackFinal(config, { configType }) {
    // apply any global webpack configs that might have been specified in .storybook/main.js
    if (rootMain.webpackFinal) {
      config = await rootMain.webpackFinal(config, { configType });
    }

    // add your own webpack tweaks if needed

    return config;
  }
};


Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mandarinicommented, Jun 9, 2022

Hi @Jordan-Hall ! I’m testing this out, right now!

Sooooo, great news!!!

I just tested this! I installed vite and @storybook/builder-vite. Then, in my React projects’s .storybook/main.js I changed the builder to this: builder: '@storybook/builder-vite'.

Then I just did nx storybook my-project and it works like a charm.

Screenshot 2022-06-09 at 12 40 40 PM

Here is my repo. I had to do nothing more, it just works! I just need to remove that webpack4 message, which is disorienting! Here are the changes from the default Storybook setup as Nx creates it, to move to vite.

Please please let me know if it works for you!

You can also read the docs on the vite builder!

1reaction
Jordan-Hallcommented, Jun 8, 2022

I’ll let you know if this is exactly the issue. WIth the setup I have it appears to still be running on webpack (At least thats what it says). I notice now https://github.com/nrwl/nx/issues/10584 is saying bable-loader being used so will need to debug for longer. However at the same time all the viteFinal config is being called as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure Storybook
To control the way stories are rendered and add global decorators and parameters, create a .storybook/preview.js file. This is loaded in the Canvas...
Read more >
[Feature] Angular 6 Builder #3995 - storybookjs/storybook
Solve multiple issues [Support] Storybook + Angular 6 multiple apps ... I can't think of a reason Storybook should add a builder for...
Read more >
How to build a Storybook addon - Chromatic
UI-based addons · 1. You can add a tool to the Toolbar, for example the Grid and Background tools · 2. Create an...
Read more >
Angular: Storybook Webpack Migration - Nx
The easiest way is probably to generate a new library and Storybook configuration and then copy & paste the main.js . 2. Move...
Read more >
The specified command ("storybook") is invalid. For a list of ...
im my angular 13.1.1 application i added storybook and manually adding angular cli build option to the project so that it will use...
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