Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function devOrBuild({ cwd, cmd, DOC_PATH, args = {} }: Partial) {
const { storybookPath } = generator(cwd);
if (cmd === 'build') {
return storybook({
mode: 'static',
outputDir: DOC_PATH,
configDir: storybookPath,
});
} else {
// Dev mode
process.env.NODE_ENV = 'development';
return storybook({
mode: 'dev',
port: args.port || 9001,
configDir: storybookPath,
});
}
}
await check();
let result = await runWebpack(appConfiguration);
if (result.stats.hasErrors()) {
throw new Error();
}
if (prerenderConfiguration) {
result = await runWebpack(prerenderConfiguration);
if (result.stats.hasErrors()) {
throw new Error();
}
}
const storybookConfigDir = path.resolve(process.cwd(), '.storybook');
if (fs.existsSync(storybookConfigDir)) {
await storybook({
mode: 'static',
configDir: storybookConfigDir,
outputDir: './build/storybook',
});
}
}