Skip to content

Commit

Permalink
Merge pull request #17320 from storybookjs/fix-builder-config-object
Browse files Browse the repository at this point in the history
Addon-docs: Fix `BuilderConfig` can be an object
  • Loading branch information
shilman committed Jan 24, 2022
2 parents 2a1c212 + 033ace8 commit 9f1bf78
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions addons/docs/src/frameworks/common/preset.ts
Original file line number Diff line number Diff line change
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

0 comments on commit 9f1bf78

Please sign in to comment.