You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cli.md
+23-8Lines changed: 23 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -128,26 +128,41 @@ vue build MyComponent.vue
128
128
129
129
### Installing Plugins in an Existing Project
130
130
131
-
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, simply install it first:
131
+
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:
132
132
133
133
```sh
134
-
npm install -D @vue/cli-plugin-eslint
134
+
vue add @vue/eslint
135
135
```
136
136
137
-
Then you can invoke the plugin's generator so it generates files into your project:
137
+
> Note: it is recommended to commit your project's current state before running `vue add`, since the command will invoke the plugin's file generator and potentially make changes to your existing files.
138
+
139
+
The command resolves `@vue/eslint` to the full package name `@vue/cli-plugin-eslint`, installs it from npm, and invokes its generator.
140
+
141
+
```sh
142
+
# these are equivalent to the previous usage
143
+
vue add @vue/cli-plugin-eslint
144
+
```
145
+
146
+
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`:
147
+
148
+
```sh
149
+
# installs and invokes vue-cli-plugin-apollo
150
+
vue add apollo
151
+
```
152
+
153
+
You can also use 3rd party plugins under a specific scope. For example, if a plugin is named `@foo/vue-cli-plugin-bar`, you can add it with:
138
154
139
155
```sh
140
-
# the @vue/cli-plugin- prefix can be omitted
141
-
vue invoke eslint
156
+
vue add @foo/bar
142
157
```
143
158
144
-
In addition, you can pass options to the plugin:
159
+
Finally, you can pass generator options to the installed plugin:
145
160
146
161
```sh
147
-
vue invoke eslint --config airbnb --lintOn save
162
+
vue add @vue/eslint --config airbnb --lintOn save
148
163
```
149
164
150
-
It is recommended to commit your project's current state before running `vue invoke`, so that after file generation you can review the changes and revert if needed.
165
+
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`.
0 commit comments