Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAngular - Passing CLI Parameters with storybook #8652
Comments
|
Automention: Hey @MaximSagan @igor-dv @kroeder, you've been tagged! Can you give a hand here? |
|
Interesting idea. Do you need
Can you specify what exactly you need? Maybe add a short real-world use-case snippet as a comment? |
|
H @kroeder , thanks for looking in to this. I am building a white-labeled app, that can support custom SCSS, assets, and other client configurations based on a configuration parameter. The below configuration, set in angular.json, is applied by running -c client1 or --configuration=client1.
So in storybook I would like to do the same, i.e. npm run storybook -c client1 (or with an env variable that hooks into the angular -c), but I would imagine it could be difficult if you are not wrapping the CLI already. |
|
A short insight of how storybook currently extracts a project from the angular.json: https://github.com/storybookjs/storybook/blob/next/app/angular/src/server/angular-cli_config.ts#L60 It's this order:
I think having a way of choosing a certain project with something like @shilman @ndelangen this wouldn't be framework agnostic, though. Do we even have non-framework agnostic code in the storybook CLI? This seems to be a very small change to Are there alternatives? |
|
Thats a really cool insight, I was not aware it would prioritize a storybook project. Is it possible to have a library as a project? For my use case though I am requesting something a bit different. The "project" consist of shared configurations for multiple clients, and the "configuration" is client specific. So I would want to run start-storybook --ngCliProject storybook --ngCliConfiguration client1 i.e. to show client1 themed ui components in isolation. A solution could be to override the options in Instead it would be something like |
@kroeder I'm more than interested in contribution to this feature. We're working in monorepo setup, Nrwl Nx tooling and having multiple projects requires to run different configurations which resulted running into dead end. The dirtiest way would be simple file replacement inside But I'm not a fan of the solution, I'd rather see some mechanism which scales and it's easily testable. I would expect as a developer either to have an opportunity to write some custom Webpack plugin which would be responsible for the If there's no easy solution/answer to this, do you advice to go for the quick and dirty file replacement of defaultProject before script runs? |


When building and running storybook I would like to be able to pass parameters for angular.json. For instance injecting configurations in Angular is done with "ng serve -c my-config" or "ng build -c my-config" and I would like to do the same when running Angular inside storybook.
As Angular does not support environment variables that is not an option.