Skip to content

Commit

Permalink
more readme tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 29, 2017
1 parent f787984 commit f6ea76c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,39 @@ Plugins are locally installed into the project as devDependencies. `@vue/cli-ser
A plugin should export a function which receives two arguments:

- A [PluginAPI][7] instance
- Project local options specified in `vue.config.js`
- Project local options specified in `vue.config.js`, or in the `"vue-cli"` field in `package.json`.

The API allows plugins to extend/modify the internal webpack config for different environments and inject additional commands to `vue-cli-service`.
The API allows plugins to extend/modify the internal webpack config for different environments and inject additional commands to `vue-cli-service`. Example:

``` js
module.exports = (api, options) => {
api.configureWepback(config => {
// modify webpack config
})

api.regsiterCommand('test', args => {
// register `vue-cli-service test`
})
}
```

### Generator

A plugin published as a package can also contain a `generator.js` file or a `generator` directory with `index.js`. The generator inside a plugin will be invoked after the plugin is installed.

A generator should export a function which receives a [GeneratorAPI][3] instance as the only argument. The API allows a generator to inject additional dependencies or fields into `package.json` and add files to the project.
A generator should export a function which receives a [GeneratorAPI][3] instance as the only argument. The API allows a generator to inject additional dependencies or fields into `package.json` and add files to the project. Example:

``` js
module.exports = (api, options) => {
api.extendPackage({
scripts: {
test: 'vue-cli-service test'
}
})

api.renderFiles('./files')
}
```

[1]: https://github.com/vuejs/vue-cli/tree/next/packages/@vue/cli/lib/Creator.js
[3]: https://github.com/vuejs/vue-cli/tree/next/packages/@vue/cli/lib/GeneratorAPI.js
Expand Down
1 change: 0 additions & 1 deletion packages/@vue/cli/lib/util/installDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = function installDeps (command, targetDir, deps) {
if (deps) {
args.push('add', '--dev')
}
args.push('--silent')
} else {
throw new Error(`unknown package manager: ${command}`)
}
Expand Down

0 comments on commit f6ea76c

Please sign in to comment.