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

Addon-docs: Fix BuilderConfig can be an object #17320

Merged
merged 1 commit into from Jan 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions addons/docs/src/frameworks/common/preset.ts
Expand Up @@ -4,7 +4,7 @@ import remarkExternalLinks from 'remark-external-links';

// @ts-ignore
import { createCompiler } from '@storybook/csf-tools/mdx';
import type { Options } from '@storybook/core-common';
import type { BuilderConfig, Options } from '@storybook/core-common';

// for frameworks that are not working with react, we need to configure
// the jsx to transpile mdx, for now there will be a flag for that
Expand Down Expand Up @@ -38,12 +38,15 @@ export async function webpack(
typeof createCompiler
>[0]
) {
const { builder = 'webpack4' } = await options.presets.apply<{ builder: any }>('core', {} as any);
const { builder = 'webpack4' } = await options.presets.apply<{
builder: BuilderConfig;
}>('core', {} as any);

const builderName = typeof builder === 'string' ? builder : builder.name;
const resolvedBabelLoader = require.resolve('babel-loader', {
paths: builder.match(/(webpack4|webpack5)/)
paths: builderName.match(/(webpack4|webpack5)/)
? [require.resolve(`@storybook/builder-${builder}`)]
: [builder],
: [builderName],
});

const { module = {} } = webpackConfig;
Expand Down