Skip to content

Commit

Permalink
Merge pull request #14479 from storybookjs/14458-fix-configjs-configu…
Browse files Browse the repository at this point in the history
…ration

Core: Fix config.js-based configuration
  • Loading branch information
shilman committed Apr 5, 2021
2 parents 0cbd527 + 8ba39ae commit e65d987
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/core-server/src/utils/get-preview-builder.ts
@@ -1,10 +1,13 @@
import path from 'path';
import { getInterpretedFile, serverRequire, Options } from '@storybook/core-common';

const DEFAULT_WEBPACK = 'webpack4';

export async function getPreviewBuilder(configDir: Options['configDir']) {
const main = path.resolve(configDir, 'main');
const { core } = serverRequire(getInterpretedFile(main));
const builder = core?.builder || 'webpack4';
const mainFile = getInterpretedFile(main);
const { core } = mainFile ? serverRequire(mainFile) : { core: null };
const builder = core?.builder || DEFAULT_WEBPACK;

const previewBuilder = await import(`@storybook/builder-${builder}`);
return previewBuilder;
Expand Down

0 comments on commit e65d987

Please sign in to comment.