mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-22 12:28:44 -05:00
feat: allow omitting scope prefix for official plugins on vue add (#4219)
This commit is contained in:
@@ -29,7 +29,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/babel
|
||||
vue add babel
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -29,7 +29,7 @@ Cypress offers a rich interactive interface for running E2E tests, but currently
|
||||
|
||||
- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
|
||||
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
|
||||
|
||||
|
||||
Examples :
|
||||
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`
|
||||
|
||||
@@ -44,5 +44,5 @@ Cypress doesn't load .env files for your test files the same way as `vue-cli` do
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/e2e-cypress
|
||||
vue add e2e-cypress
|
||||
```
|
||||
|
||||
@@ -33,5 +33,5 @@ Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gett
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/e2e-nightwatch
|
||||
vue add e2e-nightwatch
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/eslint
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -127,7 +127,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/pwa
|
||||
vue add pwa
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -27,7 +27,7 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/typescript
|
||||
vue add typescript
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -36,7 +36,7 @@ Jest can be configured via `jest.config.js` in your project root, or the `jest`
|
||||
## Installing in an Already Created Project
|
||||
|
||||
```sh
|
||||
vue add @vue/unit-jest
|
||||
vue add unit-jest
|
||||
```
|
||||
|
||||
## Transform dependencies from `/node_modules`
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/unit-mocha
|
||||
vue add unit-mocha
|
||||
```
|
||||
|
||||
@@ -15,7 +15,7 @@ You can install and manage Plugins using the GUI with the `vue ui` command.
|
||||
Each CLI plugin ships with a generator (which creates files) and a runtime plugin (which tweaks the core webpack config and injects commands). When you use `vue create` to create a new project, some plugins will be pre-installed for you based on your feature selection. In case you want to install a plugin into an already created project, you can do so with the `vue add` command:
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
::: tip
|
||||
@@ -30,7 +30,7 @@ The command resolves `@vue/eslint` to the full package name `@vue/cli-plugin-esl
|
||||
|
||||
``` bash
|
||||
# these are equivalent to the previous usage
|
||||
vue add @vue/cli-plugin-eslint
|
||||
vue add cli-plugin-eslint
|
||||
```
|
||||
|
||||
Without the `@vue` prefix, the command will resolve to an unscoped package instead. For example, to install the 3rd party plugin `vue-cli-plugin-apollo`:
|
||||
@@ -49,7 +49,7 @@ vue add @foo/bar
|
||||
You can pass generator options to the installed plugin (this will skip the prompts):
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint --config airbnb --lintOn save
|
||||
vue add eslint --config airbnb --lintOn save
|
||||
```
|
||||
|
||||
If a plugin is already installed, you can skip the installation and only invoke its generator with the `vue invoke` command. The command takes the same arguments as `vue add`.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
Каждый плагин для CLI поставляется с генератором (который создаёт файлы) и плагином для runtime (который меняет конфигурацию webpack и внедряет команды). Когда вы используете `vue create` для создания нового проекта, некоторые плагины будут уже предустановлены, в зависимости от вашего выбора необходимых возможностей. В случае, когда необходимо установить плагин в уже существующий проект, вы должны сделать это командой `vue add`:
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
::: tip Совет
|
||||
@@ -30,7 +30,7 @@ vue add @vue/eslint
|
||||
|
||||
``` bash
|
||||
# это аналогично предыдущей команде
|
||||
vue add @vue/cli-plugin-eslint
|
||||
vue add cli-plugin-eslint
|
||||
```
|
||||
|
||||
Без префикса `@vue` команда будет трансформировать название к публичному пакету. Например, чтобы установить сторонний плагин `vue-cli-plugin-apollo`:
|
||||
@@ -49,7 +49,7 @@ vue add @foo/bar
|
||||
Можно передавать опции генерации в установленный плагин (для пропуска интерактивного выбора):
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint --config airbnb --lintOn save
|
||||
vue add eslint --config airbnb --lintOn save
|
||||
```
|
||||
|
||||
Если плагин уже установлен, вы можете пропустить установку и только вызвать его генератор с помощью команды `vue invoke`. Команда принимает такие же аргументы, как и `vue add`.
|
||||
|
||||
@@ -15,7 +15,7 @@ Vue CLI 使用了一套基于插件的架构。如果你查阅一个新创建项
|
||||
每个 CLI 插件都会包含一个 (用来创建文件的) 生成器和一个 (用来调整 webpack 核心配置和注入命令的) 运行时插件。当你使用 `vue create` 来创建一个新项目的时候,有些插件会根据你选择的特性被预安装好。如果你想在一个已经被创建好的项目中安装一个插件,可以使用 `vue add` 命令:
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
::: tip 提示
|
||||
@@ -30,7 +30,7 @@ vue add @vue/eslint
|
||||
|
||||
``` bash
|
||||
# 这个和之前的用法等价
|
||||
vue add @vue/cli-plugin-eslint
|
||||
vue add cli-plugin-eslint
|
||||
```
|
||||
|
||||
如果不带 `@vue` 前缀,该命令会换作解析一个 unscoped 的包。例如以下命令会安装第三方插件 `vue-cli-plugin-apollo`:
|
||||
@@ -49,7 +49,7 @@ vue add @foo/bar
|
||||
你可以向被安装的插件传递生成器选项 (这样做会跳过命令提示):
|
||||
|
||||
``` bash
|
||||
vue add @vue/eslint --config airbnb --lintOn save
|
||||
vue add eslint --config airbnb --lintOn save
|
||||
```
|
||||
|
||||
如果一个插件已经被安装,你可以使用 `vue invoke` 命令跳过安装过程,只调用它的生成器。这个命令会接受和 `vue add` 相同的参数。
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/babel
|
||||
vue add babel
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -29,7 +29,7 @@ Cypress offers a rich interactive interface for running E2E tests, but currently
|
||||
|
||||
- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
|
||||
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
|
||||
|
||||
|
||||
Examples :
|
||||
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`
|
||||
|
||||
@@ -44,5 +44,5 @@ Cypress doesn't load .env files for your test files the same way as `vue-cli` do
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/e2e-cypress
|
||||
vue add e2e-cypress
|
||||
```
|
||||
|
||||
@@ -33,5 +33,5 @@ Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gett
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/e2e-nightwatch
|
||||
vue add e2e-nightwatch
|
||||
```
|
||||
|
||||
@@ -63,7 +63,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/eslint
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -127,7 +127,7 @@ module.exports = {
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/pwa
|
||||
vue add pwa
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/router
|
||||
vue add router
|
||||
```
|
||||
|
||||
@@ -27,7 +27,7 @@ If opted to use [TSLint](https://palantir.github.io/tslint/) during project crea
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/typescript
|
||||
vue add typescript
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
@@ -36,7 +36,7 @@ Jest can be configured via `jest.config.js` in your project root, or the `jest`
|
||||
## Installing in an Already Created Project
|
||||
|
||||
```sh
|
||||
vue add @vue/unit-jest
|
||||
vue add unit-jest
|
||||
```
|
||||
|
||||
## Transform dependencies from `/node_modules`
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/unit-mocha
|
||||
vue add unit-mocha
|
||||
```
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
## Installing in an Already Created Project
|
||||
|
||||
``` sh
|
||||
vue add @vue/vuex
|
||||
vue add vuex
|
||||
```
|
||||
|
||||
@@ -2,6 +2,19 @@ const pluginRE = /^(@vue\/|vue-|@[\w-]+\/vue-)cli-plugin-/
|
||||
const scopeRE = /^@[\w-]+\//
|
||||
const officialRE = /^@vue\//
|
||||
|
||||
const officialPlugins = [
|
||||
'babel',
|
||||
'e2e-cypress',
|
||||
'e2e-nightwatch',
|
||||
'eslint',
|
||||
'pwa',
|
||||
'router',
|
||||
'typescript',
|
||||
'unit-jest',
|
||||
'unit-mocha',
|
||||
'vuex'
|
||||
]
|
||||
|
||||
exports.isPlugin = id => pluginRE.test(id)
|
||||
|
||||
exports.isOfficialPlugin = id => exports.isPlugin(id) && officialRE.test(id)
|
||||
@@ -14,6 +27,9 @@ exports.resolvePluginId = id => {
|
||||
if (pluginRE.test(id)) {
|
||||
return id
|
||||
}
|
||||
if (officialPlugins.includes(id)) {
|
||||
return `@vue/cli-plugin-${id}`
|
||||
}
|
||||
// scoped short
|
||||
// e.g. @vue/foo, @bar/foo
|
||||
if (id.charAt(0) === '@') {
|
||||
|
||||
Reference in New Issue
Block a user