Skip to content

Commit

Permalink
fix: allow v3 cli to invoke vuex & router plugin from inside cli-serv…
Browse files Browse the repository at this point in the history
…ice (#4696)
  • Loading branch information
sodatea committed Oct 17, 2019
1 parent eec84c0 commit a759af1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
33 changes: 2 additions & 31 deletions packages/@vue/cli-service/generator/index.js
@@ -1,5 +1,3 @@
const { execa } = require('@vue/cli-shared-utils')

module.exports = (api, options) => {
api.render('./template', {
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript')
Expand Down Expand Up @@ -58,39 +56,12 @@ module.exports = (api, options) => {

// for v3 compatibility
if (options.router && !api.hasPlugin('router')) {
api.extendPackage({
devDependencies: {
'@vue/cli-plugin-router': '^4.0.0'
}
})

api.onCreateComplete(() => {
execa.sync('vue', [
'invoke',
'@vue/cli-plugin-router',
`--historyMode=${options.routerHistoryMode ? 'true' : ''}`
], {
cwd: api.resolve('.')
})
})
require('./router')(api, options)
}

// for v3 compatibility
if (options.vuex && !api.hasPlugin('vuex')) {
api.extendPackage({
devDependencies: {
'@vue/cli-plugin-vuex': '^4.0.0'
}
})

api.onCreateComplete(() => {
execa.sync('vue', [
'invoke',
'@vue/cli-plugin-vuex'
], {
cwd: api.resolve('.')
})
})
require('./vuex')(api)
}

// additional tooling configurations
Expand Down
5 changes: 5 additions & 0 deletions packages/@vue/cli-service/generator/router.js
@@ -0,0 +1,5 @@
module.exports = (api, options) => {
require('@vue/cli-plugin-vuex/generator')(api, {
historyMode: options.routerHistoryMode
})
}
3 changes: 3 additions & 0 deletions packages/@vue/cli-service/generator/vuex.js
@@ -0,0 +1,3 @@
module.exports = api => {
require('@vue/cli-plugin-vuex/generator')(api)
}
2 changes: 2 additions & 0 deletions packages/@vue/cli-service/package.json
Expand Up @@ -26,6 +26,8 @@
"@intervolga/optimize-cssnano-plugin": "^1.0.5",
"@soda/friendly-errors-webpack-plugin": "^1.7.1",
"@vue/cli-overlay": "^4.0.2",
"@vue/cli-plugin-router": "^4.0.2",
"@vue/cli-plugin-vuex": "^4.0.2",
"@vue/cli-shared-utils": "^4.0.2",
"@vue/component-compiler-utils": "^3.0.0",
"@vue/preload-webpack-plugin": "^1.1.0",
Expand Down

0 comments on commit a759af1

Please sign in to comment.