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 · 3 comments
Open

Provide Rspack Storybook builder? #92

fi3ework opened this issue Sep 14, 2024 · 3 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.

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

2 participants