Skip to content

Commit

Permalink
feat: allow specifying plugin versions in presets
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 5, 2018
1 parent eb39c91 commit bdce865
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 17 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const {
hasGit,
hasYarn,
logWithSpinner,
stopSpinner
stopSpinner,
isOfficialPlugin
} = require('@vue/cli-shared-utils')

const isManualMode = answers => answers.preset === '__manual__'
Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit bdce865

Please sign in to comment.