@nx/storybook:configuration
Add Storybook configuration to a UI library or an application.
Add Storybook configuration to a UI library or an application.
This is a framework-agnostic generator for setting up Storybook configuration for a project.
nx g @nx/storybook:configuration
Starting Nx 16, Nx does not support Storybook v6 any more. So, Nx will configure your project to use Storybook v7. If you are not on Storybook 7 yet, please migrate. You can read more about how to migrate to Storybook 7 in our Storybook 7 migration generator guide.
When running this generator, you will be prompted to provide the following:
name
of the project you want to generate the configuration for.uiFramework
you want to use. Supported values are:@storybook/angular
@storybook/html-webpack5
@storybook/nextjs
@storybook/preact-webpack5
@storybook/react-webpack5
@storybook/react-vite
@storybook/server-webpack5
@storybook/svelte-webpack5
@storybook/svelte-vite
@storybook/sveltekit
@storybook/vue-webpack5
@storybook/vue-vite
@storybook/vue3-webpack5
@storybook/vue3-vite
@storybook/web-components-webpack5
@storybook/web-components-vite
configureCypress
. If you choose yes
, a Cypress e2e app will be created (or configured) to run against the project's Storybook instance.configureTestRunner
. If you choose yes
, a test-storybook
target will be generated in your project's project.json
, with a command to invoke the Storybook test-runner
.You must provide a name
and a uiFramework
for the generator to work.
You can read more about how this generator works, in the Storybook package overview page.
If you are using Angular, React, React Native or Next.js in your project, it's best to use the framework specific generator:
React Storybook Configuration Generator (React and Next.js projects)
nx g @nx/storybook:configuration ui --uiFramework=@storybook/web-components-vite --tsConfiguration=true
This will generate a Storybook configuration for the ui
project using TypeScript for the Storybook configuration files (the files inside the .storybook
directory).
nx generate configuration ...
By default, Nx will search for configuration
in the default collection provisioned in workspace.json.
You can specify the collection explicitly as follows:
nx g @nx/storybook:configuration ...
Show what will be generated without writing to disk:
nx g configuration ... --dry-run
Project for which to generate Storybook configuration.
@storybook/angular
, @storybook/html-webpack5
, @storybook/nextjs
, @storybook/preact-webpack5
, @storybook/react-webpack5
, @storybook/react-vite
, @storybook/server-webpack5
, @storybook/svelte-webpack5
, @storybook/svelte-vite
, @storybook/sveltekit
, @storybook/vue-webpack5
, @storybook/vue-vite
, @storybook/vue3-webpack5
, @storybook/vue3-vite
, @storybook/web-components-webpack5
, @storybook/web-components-vite
Storybook UI Framework to use.
webpack
vite
, webpack
The Storybook builder to use.
Run the cypress-configure generator.
true
Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.
A directory where the Cypress project will be placed. Added at root by default.
false
Add a static-storybook to serve the static storybook built files.
Add a Storybook Test-Runner target.
false
Generate JavaScript story files rather than TypeScript story files.
eslint
eslint
, none
The tool to use for running lint checks.
false
Skip formatting files.
true
Split the project configuration into <projectRoot>/project.json
rather than including it inside workspace.json
.
Nx only supports standaloneConfig