Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/@vue/cli-service/generator/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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 @@ -54,6 +56,43 @@ 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('.')
})
})
}

// 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('.')
})
})
}

// additional tooling configurations
if (options.configs) {
api.extendPackage(options.configs)
Expand Down