mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
feat(cli): add --devtools
option for build and generate (#4357)
This commit is contained in:
parent
33d4e89925
commit
e6f73b596a
@ -19,6 +19,18 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
devtools: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Enable Vue devtools',
|
||||
prepare(cmd, options, argv) {
|
||||
options.vue = options.vue || {}
|
||||
options.vue.config = options.vue.config || {}
|
||||
if (argv.devtools) {
|
||||
options.vue.config.devtools = true
|
||||
}
|
||||
}
|
||||
},
|
||||
generate: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
|
@ -12,6 +12,18 @@ export default {
|
||||
default: true,
|
||||
description: 'Only generate pages for dynamic routes. Nuxt has to be built once before using this option'
|
||||
},
|
||||
devtools: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Enable Vue devtools',
|
||||
prepare(cmd, options, argv) {
|
||||
options.vue = options.vue || {}
|
||||
options.vue.config = options.vue.config || {}
|
||||
if (argv.devtools) {
|
||||
options.vue.config.devtools = true
|
||||
}
|
||||
}
|
||||
},
|
||||
modern: {
|
||||
...common.modern,
|
||||
description: 'Generate app in modern build (modern mode can be only client)',
|
||||
|
@ -44,6 +44,25 @@ describe('build', () => {
|
||||
expect(process.exit).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('build with devtools', async () => {
|
||||
mockGetNuxt({
|
||||
mode: 'universal'
|
||||
})
|
||||
const builder = mockGetBuilder(Promise.resolve())
|
||||
|
||||
const cmd = NuxtCommand.from(build)
|
||||
const args = ['build', '.', '--devtools']
|
||||
const argv = cmd.getArgv(args)
|
||||
argv._ = ['.']
|
||||
|
||||
const options = await cmd.getNuxtConfig(argv)
|
||||
|
||||
await cmd.run()
|
||||
|
||||
expect(options.vue.config.devtools).toBe(true)
|
||||
expect(builder).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('catches error', async () => {
|
||||
mockGetNuxt({ mode: 'universal' })
|
||||
mockGetBuilder(Promise.reject(new Error('Builder Error')))
|
||||
|
@ -46,6 +46,24 @@ describe('generate', () => {
|
||||
Command.prototype.getArgv = getArgv
|
||||
})
|
||||
|
||||
test('build with devtools', async () => {
|
||||
mockGetNuxt()
|
||||
const generator = mockGetGenerator(Promise.resolve())
|
||||
|
||||
const cmd = NuxtCommand.from(generate)
|
||||
const args = ['generate', '.', '--devtools']
|
||||
const argv = cmd.getArgv(args)
|
||||
argv._ = ['.']
|
||||
|
||||
const options = await cmd.getNuxtConfig(argv)
|
||||
|
||||
await cmd.run()
|
||||
|
||||
expect(options.vue.config.devtools).toBe(true)
|
||||
expect(generator).toHaveBeenCalled()
|
||||
expect(generator.mock.calls[0][0].build).toBe(true)
|
||||
})
|
||||
|
||||
test('catches error', async () => {
|
||||
mockGetNuxt()
|
||||
mockGetGenerator(Promise.reject(new Error('Generator Error')))
|
||||
|
Loading…
Reference in New Issue
Block a user