Skip to content

Commit 362587a

Browse files
pksunkarahaoqunjiang
authored andcommitted
feat!: make vuex a separate plugin (#4242)
fixes #2335, #4024
1 parent c0aa2bb commit 362587a

File tree

22 files changed

+98
-58
lines changed

22 files changed

+98
-58
lines changed

docs/guide/plugins-and-presets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ Here's an example preset:
105105
``` json
106106
{
107107
"useConfigFiles": true,
108-
"vuex": true,
109108
"cssPreprocessor": "sass",
110109
"plugins": {
111110
"@vue/cli-plugin-babel": {},
112111
"@vue/cli-plugin-eslint": {
113112
"config": "airbnb",
114113
"lintOn": ["save", "commit"]
115114
},
116-
"@vue/cli-plugin-router": {}
115+
"@vue/cli-plugin-router": {},
116+
"@vue/cli-plugin-vuex": {}
117117
}
118118
}
119119
```

docs/ru/guide/plugins-and-presets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ vue add @vue/eslint --config airbnb --lintOn save
105105
``` json
106106
{
107107
"useConfigFiles": true,
108-
"vuex": true,
109108
"cssPreprocessor": "sass",
110109
"plugins": {
111110
"@vue/cli-plugin-babel": {},
112111
"@vue/cli-plugin-eslint": {
113112
"config": "airbnb",
114113
"lintOn": ["save", "commit"]
115114
},
116-
"@vue/cli-plugin-router": {}
115+
"@vue/cli-plugin-router": {},
116+
"@vue/cli-plugin-vuex": {}
117117
}
118118
}
119119
```

docs/zh/guide/plugins-and-presets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ vue add @vue/eslint --config airbnb --lintOn save
105105
``` json
106106
{
107107
"useConfigFiles": true,
108-
"vuex": true,
109108
"cssPreprocessor": "sass",
110109
"plugins": {
111110
"@vue/cli-plugin-babel": {},
112111
"@vue/cli-plugin-eslint": {
113112
"config": "airbnb",
114113
"lintOn": ["save", "commit"]
115114
},
116-
"@vue/cli-plugin-router": {}
115+
"@vue/cli-plugin-router": {},
116+
"@vue/cli-plugin-vuex": {}
117117
}
118118
}
119119
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__tests__
2+
__mocks__
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# @vue/cli-plugin-vuex
2+
3+
> vuex plugin for vue-cli
4+
5+
## Installing in an Already Created Project
6+
7+
``` sh
8+
vue add @vue/vuex
9+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin')
2+
3+
test('base', async () => {
4+
const { files, pkg } = await generateWithPlugin({
5+
id: 'vuex',
6+
apply: require('../generator'),
7+
options: {}
8+
})
9+
10+
expect(files['src/store/index.js']).toBeTruthy()
11+
expect(files['src/store/index.js']).toMatch('import Vuex')
12+
13+
expect(pkg.dependencies).toHaveProperty('vuex')
14+
})

packages/@vue/cli-service/generator/vuex/index.js renamed to packages/@vue/cli-plugin-vuex/generator/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
module.exports = (api, options) => {
1+
module.exports = (api, options = {}) => {
2+
api.assertCliVersion('^4.0.0-alpha.3')
3+
api.assertCliServiceVersion('^4.0.0-alpha.3')
4+
25
api.injectImports(api.entryFile, `import store from './store'`)
36
api.injectRootOptions(api.entryFile, `store`)
7+
48
api.extendPackage({
59
dependencies: {
610
vuex: '^3.0.1'
711
}
812
})
9-
api.render('./template')
13+
14+
api.render('./template', {
15+
})
1016

1117
if (api.invoking && api.hasPlugin('typescript')) {
1218
/* eslint-disable-next-line node/no-extraneous-require */

packages/@vue/cli-service/generator/vuex/template/src/store.js renamed to packages/@vue/cli-plugin-vuex/generator/template/src/store/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ Vue.use(Vuex)
55

66
export default new Vuex.Store({
77
state: {
8-
98
},
109
mutations: {
11-
1210
},
1311
actions: {
14-
12+
},
13+
modules: {
1514
}
1615
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = (api, options = {}) => {}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@vue/cli-plugin-vuex",
3+
"version": "4.0.0-alpha.3",
4+
"description": "Vuex plugin for vue-cli",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/vuejs/vue-cli.git",
9+
"directory": "packages/@vue/cli-plugin-vuex"
10+
},
11+
"keywords": [
12+
"vue",
13+
"cli",
14+
"vuex"
15+
],
16+
"author": "Evan You",
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/vuejs/vue-cli/issues"
20+
},
21+
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-vuex#readme",
22+
"publishConfig": {
23+
"access": "public"
24+
},
25+
"dependencies": {},
26+
"devDependencies": {
27+
"@vue/cli-test-utils": "^4.0.0-alpha.3"
28+
}
29+
}

0 commit comments

Comments
 (0)