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

Provide Rspack Storybook builder? #92

Open
fi3ework opened this issue Sep 14, 2024 · 5 comments
Open

Provide Rspack Storybook builder? #92

fi3ework opened this issue Sep 14, 2024 · 5 comments

Comments

@fi3ework
Copy link
Member

fi3ework commented Sep 14, 2024

Please use the reaction with 👍 to vote for support Rspack bulider with Storybook.

@fi3ework fi3ework changed the title A simple way to compatible with Rspack project. Provide a simple way to compatible with Rspack project. Sep 14, 2024
@Narretz
Copy link

Narretz commented Oct 8, 2024

This would be really great. For example, if you're migrating a project from webpack to rspack, you don't need rsbuild. But then you want to migrate storybook as well, and you suddenly need rsbuild, which comes with its own dependencies, config file and plugins. I don't think specific rspack frameworks are the way to go, but if storybook-rsbuild could support reading a rspack.config instead of an rsbuild.config, that would be great.

e: I realized that the rspack config of an app will always be somewhat incompatible with storybook. But rsbuild does make it easy to re-use the config you need. Here's for example my minimal vue3 + storybook + rsbuild via rspack config:

import { DefinePlugin } from '@rspack/core';
import { defineConfig } from '@rsbuild/core';
import rspackAppConfig from '../packages/client/rspack.config';
import { VueLoaderPlugin } from 'vue-loader';

export default defineConfig({
  tools: {
    rspack: (config, { mergeConfig }) => {
      const appConfig = rspackAppConfig({});

      return mergeConfig(
        config,
        {
          module: appConfig.module,
          resolve: appConfig.resolve,
          experiments: appConfig.experiments,
          plugins: [new VueLoaderPlugin()],
        },
        {
          resolve: {
            alias: {
             // for string component templates
              vue: 'vue/dist/vue.esm-bundler.js',
            },
          },
          plugins: [
            new DefinePlugin({
              __VUE_OPTIONS_API__: 'true',
              __VUE_PROD_DEVTOOLS__: 'false',
              __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
            }),
          ],
        }
      );
    },
  },
});

Maybe something like this could be added to the docs.

@fi3ework fi3ework pinned this issue Oct 9, 2024
@fi3ework fi3ework changed the title Provide a simple way to compatible with Rspack project. Provide Rspack Storybook builder? Oct 9, 2024
@fi3ework
Copy link
Member Author

fi3ework commented Oct 9, 2024

Maybe something like this could be added to the docs.

This is a way to use Rspack config with storybook-builder-rsbuild, but it's not verified in many scenes. Rsbuild has many built-in features, so that may cause an implicit difference. Providing Rspack builder is not hard IMO, we're considering to support in the future.

@Narretz
Copy link

Narretz commented Oct 9, 2024

You are right, my example doesn't actually work when building, only when watching. In build mode, experiments: css extracts the css into chunks, but storybook / rsbuild expects the original chunks for each vue component. Or something like that.

@szimek
Copy link

szimek commented Nov 4, 2024

This would be awesome to have. We're trying to migrate a pretty big and old project from webpack to rspack. It all works and the performance is so much better (e.g. hmr time was reduced from ~8s to ~0.5s), but Storybook is unfortunately a blocker for us. Maybe we could keep using webpack just for Storybook for now and use rspack for the app.

@fi3ework
Copy link
Member Author

fi3ework commented Nov 4, 2024

I'll take a time to check out how to extract the webpack / Rspack configurations from webpack.config.js / rspack.config.js.

TBH, as per #88 (comment). It's possible to achieve of reuse of webpack config, the remaining questions are:

  • We need to maintain the current implementation with Rsbuild, even we don't need to use with it, to make the architecture isomorphic. Or, add a layer to work with raw Rspack, and change the Rsbuild on top of it.
  • We need to reset some configurations in Rsbuild and preserve the dev server part, as it will be overridden by Storybook anyway.

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

No branches or pull requests

3 participants