Comments (6)
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 (storybookjs/storybook#12291)
Also here is the requested Controls query params support feature storybookjs/storybook#12728. I guess it will be released very soon. But it's not enough to migrate to autogenerated Controls.
And here is why:
- Storybook Controls automatic generation is based on Storybook Docs.
- Storybook Docs does not generate automatically for Angular. It requires compodoc generated JSON file.
- You have to manually regenerate compodoc on each components change with npm run docs:json. Excerpt from https://github.com/storybookjs/storybook/tree/master/addons/docs/angular:
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.
- NX has support for compodoc with @twittwer/compodoc. But it also requires projectname:compodoc:json
execution after any change in components occurs. - compodoc does not support --watch when it's exported in JSON format. Stated in compodoc/compodoc#862. This issue was added to the 1.1.12 milestone but was closed on Jun 25, 2020 due to inactivity.
How I configure NX workspace for Angular with Storybook Controls and Storybook Docs and Compodoc:
- ng add @twittwer/compodoc
- ng generate @twittwer/compodoc:config projectname --workspaceDocs
- ng run projectname:compodoc:json
- ng add @nrwl/storybook
- ng generate @nrwl/angular:storybook-configuration projectname
- Install Storybook Essentials addons and configure them in the NX workspace storybook as described here https://www.npmjs.com/package/@storybook/addon-essentials
- Tune configuration for Storybook Docs as described here https://github.com/storybookjs/storybook/tree/master/addons/docs/angular
- Create a story and export default with defined component.
- ng run projectname:storybook
- Rerun on each component change: ng run projectname:compodoc:json
- NX Storybook plugin is running in watch mode and it automatically reloads new compodoc JSON file.
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?
from nx-tools.
The watch option was not passed to compodoc but that wouldn't work for the json format anyway => compodoc/compodoc#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:
- Add a watch configuration to your compodoc architect
"configurations": {
"json": {
"exportFormat": "json"
},
"watch": {
"exportFormat": "json",
"watch": true
}
}
- Add a storydoc architect with a run-command builder:
"storydoc": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"nx run <project>:compodoc:watch",
"nx run <project>:storybook"
]
}
}
from nx-tools.
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?
from nx-tools.
@dobromyslov Thx for the detailed answer 👍
(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.
from nx-tools.
@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.
from nx-tools.
Watchmode with json now works: compodoc/compodoc#1087
from nx-tools.
Related Issues (20)
- Npm package @twittwer/compodoc not found HOT 2
- Unhandled Rejection HOT 5
- Not able to `nx add @twittwer/compodoc` HOT 1
- Watch mode for workspaceDocs. Server doesn't reload after changing source files. HOT 4
- compdoc nx plugin: support nx per-project configuration HOT 7
- Use Compodoc watch json mode HOT 2
- Is there a way to just document the libraries? HOT 2
- No longer adds `'compodoc'` target to `cacheableOperations` HOT 2
- [Bug] Nx + Angular (v13): tsconfig path error HOT 3
- Do not use package manager bin to execute compodoc HOT 1
- Cache not reverted when not setting output path options HOT 4
- Error during /***/***/my-project/libs/shared/ui/package.json read HOT 1
- Add some doc for developer participation (have issues) HOT 1
- error on storybook-watch with windows HOT 1
- Support for nx 14 HOT 2
- Workspace docs & unit test coverage HOT 4
- Code documentation coverage not available HOT 2
- Cannot find module 'nx/src/generators/utils/json' HOT 2
- migrate to nx 16 HOT 1
- [Bug] Package "@twittwer/compodoc" was found but does not support schematics HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nx-tools.