mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Use JS only story glob extension patterns in JavaScript projects
This commit is contained in:
parent
aee10a90b8
commit
74646c68da
@ -29,7 +29,7 @@ describe('configureMain', () => {
|
||||
expect(mainConfigContent).toMatchInlineSnapshot(`
|
||||
"/** @type { import('@storybook/react-vite').StorybookConfig } */
|
||||
const config = {
|
||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs)'],
|
||||
addons: [],
|
||||
framework: {
|
||||
name: '@storybook/react-vite',
|
||||
@ -95,7 +95,7 @@ describe('configureMain', () => {
|
||||
|
||||
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
|
||||
const config = {
|
||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs)'],
|
||||
addons: [
|
||||
path.dirname(require.resolve(path.join('@storybook/addon-links', 'package.json'))),
|
||||
path.dirname(require.resolve(path.join('@storybook/addon-essentials', 'package.json'))),
|
||||
|
@ -49,6 +49,8 @@ const sanitizeFramework = (framework: string) => {
|
||||
return matches[0];
|
||||
};
|
||||
|
||||
const typescriptExtensions = ['ts', 'tsx', 'mts', 'cts'];
|
||||
|
||||
export async function configureMain({
|
||||
addons,
|
||||
extensions = ['js', 'jsx', 'mjs', 'ts', 'tsx'],
|
||||
@ -57,10 +59,14 @@ export async function configureMain({
|
||||
prefixes = [],
|
||||
...custom
|
||||
}: ConfigureMainOptions) {
|
||||
const isLanguageJavascript = language === SupportedLanguage.JAVASCRIPT;
|
||||
const filteredExtensions = extensions.filter((extension) =>
|
||||
isLanguageJavascript ? !typescriptExtensions.includes(extension) : true
|
||||
);
|
||||
const srcPath = path.resolve(storybookConfigFolder, '../src');
|
||||
const prefix = (await fse.pathExists(srcPath)) ? '../src' : '../stories';
|
||||
const config = {
|
||||
stories: [`${prefix}/**/*.mdx`, `${prefix}/**/*.stories.@(${extensions.join('|')})`],
|
||||
stories: [`${prefix}/**/*.mdx`, `${prefix}/**/*.stories.@(${filteredExtensions.join('|')})`],
|
||||
addons,
|
||||
...custom,
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ const publish = async (packages: { name: string; location: string }[], url: stri
|
||||
const command = `cd ${path.resolve(
|
||||
'../code',
|
||||
location
|
||||
)} && yarn pack --out=${PACKS_DIRECTORY}/${tarballFilename} && cd ${PACKS_DIRECTORY} && npm publish ./${tarballFilename} --registry ${url} --force --access restricted --ignore-scripts`;
|
||||
)} && yarn pack --out=${PACKS_DIRECTORY}/${tarballFilename} && cd ${PACKS_DIRECTORY} && npm publish ./${tarballFilename} --registry ${url} --force --ignore-scripts`;
|
||||
exec(command, (e) => {
|
||||
if (e) {
|
||||
rej(e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user