Skip to content

Commit bdce865

Browse files
committed
feat: allow specifying plugin versions in presets
1 parent eb39c91 commit bdce865

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: docs/cli.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ A preset is defined in JSON. If you have saved a preset via the command line and
8484

8585
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:
8686

87-
8887
``` js
8988
{
9089
"useConfigFiles": true,
@@ -100,6 +99,23 @@ The preset data is used by plugin generators to generate corresponding project f
10099

101100
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`.
102101

102+
#### Preset Plugin Versioning
103+
104+
You can explicitly specify versions of the plugins being used:
105+
106+
``` js
107+
{
108+
"plugins": {
109+
"@vue/cli-plugin-eslint": {
110+
"version": "^3.0.0",
111+
// ... other options for this plugin
112+
}
113+
}
114+
}
115+
```
116+
117+
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**.
118+
103119
#### Remote Presets
104120

105121
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 for: packages/@vue/cli/lib/Creator.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const {
2929
hasGit,
3030
hasYarn,
3131
logWithSpinner,
32-
stopSpinner
32+
stopSpinner,
33+
isOfficialPlugin
3334
} = require('@vue/cli-shared-utils')
3435

3536
const isManualMode = answers => answers.preset === '__manual__'
@@ -104,7 +105,8 @@ module.exports = class Creator {
104105
}
105106
const deps = Object.keys(preset.plugins)
106107
deps.forEach(dep => {
107-
pkg.devDependencies[dep] = `^${latest}`
108+
pkg.devDependencies[dep] = preset.plugins[dep].version ||
109+
(isOfficialPlugin(dep) ? `^${latest}` : `latest`)
108110
})
109111
// write package.json
110112
await writeFileTree(context, {

0 commit comments

Comments
 (0)