UNPKG

@nx/storybook

Version:

The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.

29 lines (28 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function getMainTsJsPath(host, projectConfig) { // Inferred targets from `@nx/storybook/plugin` are inferred from `.storybook/main.{js,ts,mjs,mts,cjs,cts}` so we can assume the directory. if (!projectConfig.targets) { const exts = ['js', 'ts', 'mjs', 'mts', 'cjs', 'cts']; for (const ext of exts) { const candidate = `${projectConfig.root}/.storybook/main.${ext}`; if (host.exists(candidate)) return candidate; } throw new Error(`Cannot find main Storybook file. Does this file exist? e.g. ${projectConfig.root}/.storybook/main.ts`); } let mainJsTsPath = undefined; Object.entries(projectConfig.targets).forEach(([_targetName, targetConfig]) => { if (targetConfig.executor === '@nx/storybook:storybook' || targetConfig.executor === '@storybook/angular:start-storybook') { const configDir = targetConfig.options?.configDir; if (host.exists(`${configDir}/main.js`)) { mainJsTsPath = `${configDir}/main.js`; } if (host.exists(`${configDir}/main.ts`)) { mainJsTsPath = `${configDir}/main.ts`; } } }); return mainJsTsPath; }