⚠️ Vue CLI is in Maintenance Mode!

For new projects, it is now recommended to use create-vue to scaffold Vite-based projects. Also refer to the Vue 3 Tooling Guide for the latest recommendations.

Generator API

cliVersion

Type: string

The version string for the global @vue/cli version that is invoking the plugin.

assertCliVersion

  • Arguments

    • {integer | string} range - a semver range that @vue/cli needs to satisfy
  • Usage

    While api.version can be useful in general, it's sometimes nice to just declare your version. This API exposes a simple way to do that.

    Nothing happens if the provided version is satisfied. Otherwise, an error will be thrown.

cliServiceVersion

Type: string

The version string for the project local @vue/cli-service version that is invoking the plugin.

assertCliServiceVersion

  • Arguments

    • {integer | string} range - a semver range that @vue/cli-service needs to satisfy
  • Usage

    This API exposes a simple way to declare the required project local @vue/cli-service version.

    Nothing happens if the provided version is satisfied. Otherwise, an error will be thrown.

    Note: It's recommended to use the peerDependencies field in package.json under most circumstances.

resolve

  • Arguments

    • {string} ..._paths - A sequence of relative paths or path segments
  • Returns

    • {string}- the resolved absolute path, caculated based on the current project root
  • Usage: Resolve a path for the current project

hasPlugin

  • Arguments

    • {string} id - plugin id, can omit the (@vue/|vue-|@scope/vue)-cli-plugin- prefix
    • {string} version - semver version range, optional
  • Returns

    • {boolean}
  • Usage: Check if the project has a plugin with given id. If version range is given, then the plugin version should satisfy it

addConfigTransform