Skip to content

Commit

Permalink
Fix entry file patterns in storybook plugin (resolves #313)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 27, 2023
1 parent ac0816c commit cdff59b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/plugins/storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDepen

export const CONFIG_FILE_PATTERNS = ['.storybook/{main,test-runner}.{js,ts}'];

/** @public */
export const STORIES_FILE_PATTERNS = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
const STORIES_FILE_PATTERNS = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];

const REST_ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}'];

/** @public */
export const ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}', ...STORIES_FILE_PATTERNS];
export const ENTRY_FILE_PATTERNS = [...REST_ENTRY_FILE_PATTERNS, ...STORIES_FILE_PATTERNS];

export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];

Expand All @@ -37,8 +38,11 @@ const findStorybookDependencies: GenericPluginCallback = async (configFilePath,
if (typeof pattern === 'string') return relative(cwd, join(dirname(configFilePath), pattern));
return relative(cwd, join(dirname(configFilePath), pattern.directory, pattern.files ?? STORIES_FILE_PATTERNS[0]));
});
const patterns = [...(config?.entry ?? []), ...(relativePatterns ?? [])];
const entryPatterns = (patterns.length > 0 ? patterns : ENTRY_FILE_PATTERNS).map(toEntryPattern);
const patterns = [
...(config?.entry ?? REST_ENTRY_FILE_PATTERNS),
...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : STORIES_FILE_PATTERNS),
];
const entryPatterns = patterns.map(toEntryPattern);

if (!localConfig || isProduction) return entryPatterns;

Expand Down

0 comments on commit cdff59b

Please sign in to comment.