microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.95k stars 599 forks source link

[heft] heft-storybook-plugin support "--docs" flag #4982

Open natle01 opened 1 month ago

natle01 commented 1 month ago

Summary

Extend @rushstack/heft-storybook-plugin to allow passing of Storybook flag --docs.

Need to run and build Storybook in "documentation mode" which requires passing Storybook's --docs flag.

Nice to have: Able to pass other Storybook flags, but --docs is the main one.

Possible Solution

Could be something like this to extend the schema.


"cliOptionsBuild": {
  "title": "Additional cli options to run when building",
  "description": "Add Storybook flags here to customize your build command. Example. --config-dir config/.storybook",
  "type": "string"
},
"cliOptionsServe": {
  "title": "Additional cli options to run when serving",
  "description": "Add Storybook flags here to customize your serve command. Example. --docs --config-dir config/.storybook",
  "type": "string"
}
// StorybookPlugin.ts
...
const { cliOptionsBuild, cliOptionsServe } = options;
const storybookArgs: string[] = runStorybookOptions.moduleDefaultArgs ?? [];

if (cliOptionsBuild) {
  const _args: string[] = cliOptionsBuild.split(' ');
  storybookArgs.push(_args);
}
if (cliOptionsServe) {
  const _args: string[] = cliOptionsServe.split(' ');
  storybookArgs.push(_args);
}

Standard questions

Question Answer
@rushstack/heft version? 0.68.5
Operating system? Windows
Would you consider contributing a PR? Yes
Node.js version (node -v)? 10.7.0
Question Answer
@rushstack/heft-storybook-plugin version? 0.6.51
Storybook version? 7.6.6
iclanton commented 2 weeks ago

Sounds like a useful feature. Instead of splitting by spaces, you should be able to say the cliOptionsBuild and cliOptionsServe options are string arrays.