Skip to content

The @nx/vue plugin provides various generators to help you create and configure vue projects within your Nx workspace. Below is a complete reference for all available generators and their options.

application

Create a Vue application for Nx.

Examples

{% tabs %} {% tab label=“Simple Application” %}

Create an application named my-app:

Terminal window
nx g @nx/vue:app apps/my-app

{% /tab %}

{% tab label=“Specify style extension” %}

Create an application named my-app in the my-dir directory and use scss for styles:

Terminal window
nx g @nx/vue:app apps/my-dir/my-app --style=scss

{% /tab %}

{% tab label=“Add tags” %}

Add tags to the application (used for linting).

Terminal window
nx g @nx/vue:app apps/my-app --tags=scope:admin,type:ui

{% /tab %} {% /tabs %}

Usage:

Terminal window
nx generate @nx/vue:application [options]

Aliases: app

Arguments:

Terminal window
nx generate @nx/vue:application <directory> [options]

Options

OptionTypeDescriptionDefault
bundlerstringThe bundler to use."vite"
e2eTestRunnerstringTest runner to use for end to end (E2E) tests."playwright"
inSourceTestsbooleanWhen using Vitest, separate spec files will not be generated and instead will be included within the source files. Read more on the Vitest docs site: https://vitest.dev/guide/in-source.htmlfalse
jsbooleanGenerate JavaScript files rather than TypeScript files.false
linterstringThe tool to use for running lint checks."none"
namestringThe name of the application.
rootProjectbooleanCreate a application at the root of the workspacefalse
routingbooleanGenerate application with routes.false
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting files.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
strictbooleanWhether to enable tsconfig strict mode or not.true
stylestringThe file extension to be used for style files."css"
tagsstringAdd tags to the application (used for linting).
unitTestRunnerstringTest runner to use for unit tests."none"
useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

component

Create a Vue Component for Nx.

Usage:

Terminal window
nx generate @nx/vue:component [options]

Aliases: c

Arguments:

Terminal window
nx generate @nx/vue:component <path> [options]

Options

OptionTypeDescriptionDefault
exportbooleanWhen true, the component is exported from the project index.ts (if it exists).false
fileNamestringCreate a component with this file name.
inSourceTestsbooleanWhen using Vitest, separate spec files will not be generated and instead will be included within the source files. Read more on the Vitest docs site: https://vitest.dev/guide/in-source.htmlfalse
jsbooleanGenerate JavaScript files rather than TypeScript files.false
routingbooleanGenerate a library with routes.
skipFormatbooleanSkip formatting files.false
skipTestsbooleanWhen true, does not create spec.ts test files for the new component.false

library

Create a Vue Library for an Nx workspace.

Usage:

Terminal window
nx generate @nx/vue:library [options]

Aliases: lib

Arguments:

Terminal window
nx generate @nx/vue:library <directory> [options]

Options

OptionTypeDescriptionDefault
appProjectstringThe application project to add the library route to.
bundlerstringThe bundler to use. Choosing ‘none’ means this library is not buildable."none"
componentbooleanGenerate a default component.false
importPathstringThe library name used to import it, like @myorg/my-awesome-lib.
inSourceTestsbooleanWhen using Vitest, separate spec files will not be generated and instead will be included within the source files.false
jsbooleanGenerate JavaScript files rather than TypeScript files.false
linterstringThe tool to use for running lint checks."none"
minimalbooleanCreate a Vue library with a minimal setup, no separate test files.false
namestringLibrary name
publishablebooleanCreate a publishable library.
routingbooleanGenerate library with routes.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting files.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
skipTsConfigbooleanDo not update tsconfig.json for development experience.false
strictbooleanWhether to enable tsconfig strict mode or not.true
tagsstringAdd tags to the library (used for linting).
unitTestRunnerstringTest runner to use for unit tests."none"
useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

setup-tailwind

Adds the Tailwind CSS configuration files for a given Vue project and installs, if needed, the packages required for Tailwind CSS to work.

Usage:

Terminal window
nx generate @nx/vue:setup-tailwind [options]

Arguments:

Terminal window
nx generate @nx/vue:setup-tailwind <project> [options]

Options

OptionTypeDescriptionDefault
skipFormatbooleanSkips formatting the workspace after the generator completes.
skipPackageJsonbooleanDo not add dependencies to package.json.false
stylesheetstringPath to the styles entry point relative to the workspace root. This option is only needed if the stylesheet location cannot be found automatically.

stories

Generate stories/specs for all components declared in a project.

This generator will generate stories for all your components in your project. The stories will be generated using Component Story Format 3 (CSF3).

You can also use this generator to generate stories for your Nuxt project:

Terminal window
nx g @nx/vue:stories project-name

or

Terminal window
nx g @nx/nuxt:stories project-name

You can read more about how this generator works, in the Storybook for Vue overview page.

When running this generator, you will be prompted to provide the following:

You must provide a name for the generator to work.

By default, this generator will also set up Storybook interaction tests. If you don’t want to set up Storybook interaction tests, you can pass the --interactionTests=false option, but it’s not recommended.

There are a number of other options available. Let’s take a look at some examples.

Examples

Ignore certain paths when generating stories

Terminal window
nx g @nx/vue:stories --name=ui --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*

This will generate stories for all the components in the ui project, except for the ones in the libs/ui/src/not-stories directory, and also for components that their file name is of the pattern *.other.*.

This is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component.

By default, Nx will ignore the following paths:

*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx

but you can change this behaviour easily, as explained above.

Generate stories using JavaScript instead of TypeScript

Terminal window
nx g @nx/vue:stories --name=ui --js=true

This will generate stories for all the components in the ui project using JavaScript instead of TypeScript. So, you will have .stories.js files next to your components.

Usage:

Terminal window
nx generate @nx/vue:stories [options]

Options

OptionTypeDescriptionDefault
projectstring [required]Project for which to generate stories.
ignorePathsarrayPaths to ignore when looking for components.["*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"]
interactionTestsbooleanSet up Storybook interaction tests.true
jsbooleanGenerate JavaScript files rather than TypeScript files.false
skipFormatbooleanSkip formatting files.false

storybook-configuration

Set up Storybook for a Vue project.

This generator will set up Storybook for your Vue project. You can also use this generator to generate Storybook configuration for your Nuxt project.

Terminal window
nx g @nx/vue:storybook-configuration project-name

or

Terminal window
nx g @nx/nuxt:storybook-configuration project-name

You can read more about how this generator works, in the Storybook for Vue overview page.

When running this generator, you will be prompted to provide the following:

  • The name of the project you want to generate the configuration for.
  • Whether you want to set up Storybook interaction tests (interactionTests). If you choose yes, a play function will be added to your stories, and all the necessary dependencies will be installed. Also, a test-storybook target will be generated in your project’s project.json, with a command to invoke the Storybook test-runner. You can read more about this in the Nx Storybook interaction tests documentation page..
  • Whether you want to generateStories for the components in your project. If you choose yes, a .stories.ts file will be generated next to each of your components in your project.

You must provide a name for the generator to work.

By default, this generator will also set up Storybook interaction tests. If you don’t want to set up Storybook interaction tests, you can pass the --interactionTests=false option, but it’s not recommended.

There are a number of other options available. Let’s take a look at some examples.

Examples

Generate Storybook configuration

Terminal window
nx g @nx/vue:storybook-configuration ui

This will generate Storybook configuration for the ui project using TypeScript for the Storybook configuration files (the files inside the .storybook directory, eg. .storybook/main.ts).

Ignore certain paths when generating stories

Terminal window
nx g @nx/vue:storybook-configuration ui --generateStories=true --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts

This will generate a Storybook configuration for the ui project and generate stories for all components in the libs/ui/src/lib directory, except for the ones in the libs/ui/src/not-stories directory, and the ones in the apps/my-app directory that end with .something.ts, and also for components that their file name is of the pattern *.other.*.

This is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component.

By default, Nx will ignore the following paths:

*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx

but you can change this behaviour easily, as explained above.

Generate stories using JavaScript instead of TypeScript

Terminal window
nx g @nx/vue:storybook-configuration ui --generateStories=true --js=true

This will generate stories for all the components in the ui project using JavaScript instead of TypeScript. So, you will have .stories.js files next to your components.

Generate Storybook configuration using JavaScript

Terminal window
nx g @nx/vue:storybook-configuration ui --tsConfiguration=false

By default, our generator generates TypeScript Storybook configuration files. You can choose to use JavaScript for the Storybook configuration files of your project (the files inside the .storybook directory, eg. .storybook/main.js).

Usage:

Terminal window
nx generate @nx/vue:storybook-configuration [options]

Arguments:

Terminal window
nx generate @nx/vue:storybook-configuration <project> [options]

Options

OptionTypeDescriptionDefault
configureStaticServebooleanSpecifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.true
generateStoriesbooleanAutomatically generate *.stories.ts files for components declared in this project?true
ignorePathsarrayPaths to ignore when looking for components.["*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"]
interactionTestsbooleanSet up Storybook interaction tests.true
jsbooleanGenerate JavaScript story files rather than TypeScript story files.false
linterstringThe tool to use for running lint checks."eslint"
tsConfigurationbooleanConfigure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.true
## Getting Help
You can get help for any generator by adding the `--help` flag:
```bash
nx generate @nx/vue:<generator> --help
```