diff --git a/docs/cli.md b/docs/cli.md index 7d6563ee76..ac025494c0 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -84,7 +84,6 @@ A preset is defined in JSON. If you have saved a preset via the command line and The preset data is used by plugin generators to generate corresponding project files. In addition to the above fields, you can also add additional configuration for integrated tools: - ``` js { "useConfigFiles": true, @@ -100,6 +99,23 @@ The preset data is used by plugin generators to generate corresponding project f These additional configurations will be merged into `package.json` or corresponding config files, depending on the value of `useConfigFiles`. For example, with `"useConfigFiles": true`, the value of `configs.vue` will be merged into `vue.config.js`. +#### Preset Plugin Versioning + +You can explicitly specify versions of the plugins being used: + +``` js +{ + "plugins": { + "@vue/cli-plugin-eslint": { + "version": "^3.0.0", + // ... other options for this plugin + } + } +} +``` + +Note this is not required for official plugins - when omitted, the CLI will automatically use the latest version available in the registry. However, **it is recommended to provide a explicit version range for any 3rd party plugins listed in a preset**. + #### Remote Presets You can share a preset with other developers by publishing it in a git repo. The repo should contain a `preset.json` file containing the preset data. You can then use the `--preset` option to use the remote preset when creating a project: diff --git a/packages/@vue/cli/lib/Creator.js b/packages/@vue/cli/lib/Creator.js index 4a46f39ec9..d9d57bb39a 100644 --- a/packages/@vue/cli/lib/Creator.js +++ b/packages/@vue/cli/lib/Creator.js @@ -29,7 +29,8 @@ const { hasGit, hasYarn, logWithSpinner, - stopSpinner + stopSpinner, + isOfficialPlugin } = require('@vue/cli-shared-utils') const isManualMode = answers => answers.preset === '__manual__' @@ -104,7 +105,8 @@ module.exports = class Creator { } const deps = Object.keys(preset.plugins) deps.forEach(dep => { - pkg.devDependencies[dep] = `^${latest}` + pkg.devDependencies[dep] = preset.plugins[dep].version || + (isOfficialPlugin(dep) ? `^${latest}` : `latest`) }) // write package.json await writeFileTree(context, {