Open dobromyslov opened 4 years ago
I had paused my plans when I recognized the major changes that were planned for nx's Storybook plugin (v6). As the update is now released it would be time to reevaluate my plans - especially if there is an interest 🙂 Do you have any input, wishes or expectations?
Storybook plugin for NX (https://nx.dev/latest/angular/plugins/storybook/overview) lacks of Storybook Essential addons support (https://storybook.js.org/docs/angular/essentials/introduction). NX by now uses only old the knobs addon which will be substituted by the Storybook Controls some day.
Some excerpts from NX:
Storybook v6 moves from "knobs" to args and controls when it comes to defining and manipulating your storybook component properties. Feel free to use the new args way of defining stories. More can be found on the official Storybook docs.
Note: Nx does not yet automatically generate stories that use the args syntax. The main reason is that args don't yet support being loaded via the iframe URL which is used in Nx to setup your Storybook based e2e tests. Once support is present in Storybook v6, we will provide a way to generate args & controls based stories. More on the progress here (https://github.com/storybookjs/storybook/issues/12291)
Also here is the requested Controls query params support feature https://github.com/storybookjs/storybook/pull/12728. I guess it will be released very soon. But it's not enough to migrate to autogenerated Controls.
And here is why:
Unfortunately, it's not currently possible to update this dynamically as you edit your components, but there's an open issue to support this with improvements to Compodoc.
How I configure NX workspace for Angular with Storybook Controls and Storybook Docs and Compodoc:
It's quite complicated to bootstrap this stack and rerun commands but it works at least.
While I was writing this workflow I was thinking about the root cause again... And I noticed that maybe it would be enough just to improve NX Storybook plugin to make it responsible for rerun of projectname:compodoc:json.
What do you think?
@dobromyslov Thx for the detailed answer :+1:
(A) The original idea was to create a wrapper plugin that will add a single architect with storybook & compodoc options and internally executes the 2 builders in order
(B) The simplest solution can be a schematic in the compodoc plugin that adds a run-command architect to execute compodoc & storybook in order.
(C) The next step could be a custom build that requires separate architects for compodoc & storybook and executes them in parallel while using e.g. nodemon for compodoc to achieve an auto regeneration of the docs metadata.
Option B is the solution I use currently at work for the workspace wide storybook. I know this options don't fix the initial setup, but it maybe a first step - What do you think? I could try to get some sort of POC in the next days.
@twittwer those are rather good options. (B) combined Compodoc & Storybook command helps a little on first Storybook start. Then it's running and watching for changes. And (C) option is needed to get rid of manual compodoc refresh.
I tried to run ng run projectname:compodoc:json --watch
and it does not work. Looks like either your plugin does not pass --watch
parameter to the compodoc or compodoc itself does not run in watch mode when used with JSON output format. I've not figured it out yet.
The watch option was not passed to compodoc but that wouldn't work for the json format anyway => https://github.com/compodoc/compodoc/issues/862
I just published version 1.4.0. on the next channel with a watch option as a first POC.
It worked in my scenario with the following steps:
"configurations": {
"json": {
"exportFormat": "json"
},
"watch": {
"exportFormat": "json",
"watch": true
}
}
"storydoc": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"nx run <project>:compodoc:watch",
"nx run <project>:storybook"
]
}
}
Watchmode with json now works: https://github.com/compodoc/compodoc/issues/1087
I see you've done a plugin for compodoc which is required for Storybook Docs addon to be used with Angular as described here https://github.com/storybookjs/storybook/tree/master/addons/docs/angular. And looks like there is no another easy way to generate storydocs from Angular directly according to this discussion https://github.com/storybookjs/storybook/issues/8672.
There is a milestone for the storydoc nx plugin in the twittwer/nx-tools readme. Do you have any plans to create it?