@nx/storybook
Version:
36 lines (35 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = storybookExecutor;
const utilities_1 = require("../../utils/utilities");
const semver_1 = require("semver");
const deprecation_1 = require("../../utils/deprecation");
async function* storybookExecutor(options, context) {
(0, deprecation_1.warnStorybookExecutorDeprecation)();
(0, utilities_1.storybookConfigExistsCheck)(options.configDir, context.projectName);
const buildOptions = options;
const result = await runInstance(buildOptions);
yield {
success: true,
info: {
port: result?.['port'],
baseUrl: `${options.https ? 'https' : 'http'}://${options.host ?? 'localhost'}:${result?.['port']}`,
},
};
await new Promise(() => { });
}
async function runInstance(options) {
const installedStorybookVersion = (0, utilities_1.getInstalledStorybookVersion)();
const hasCoreServerInStorybookPackage = (0, semver_1.gte)(installedStorybookVersion, '8.2.0');
const storybookCore = await (hasCoreServerInStorybookPackage
? import('storybook/internal/core-server')
: // This is needed for backwards compatibility - but we do not have the package installed in the nx repo
// @ts-ignore
import('@storybook/core-server'));
const env = process.env.NODE_ENV ?? 'development';
process.env.NODE_ENV = env;
return storybookCore.build({
...options,
mode: 'dev',
});
}